Class: GrubY::TDLib::SchemaBuilder
- Inherits:
-
Object
- Object
- GrubY::TDLib::SchemaBuilder
- Defined in:
- lib/gruubY/tdlib/schema_builder.rb
Constant Summary collapse
- TL_DEF_REGEX =
/^(?<name>\w+)(?:#[0-9a-f]+)?\s+(?<params>.*)=\s+(?<type>\w+);$/- PARAM_DETAIL_REGEX =
/(?<name>\w+):(?<type>[^\s]+)/- ROW_REGEX =
/<tr>\s*<td>(.*?)<\/td>\s*<td>(.*?)<\/td>\s*<td>(.*?)<\/td>\s*<td>(.*?)<\/td>\s*<\/tr>/m- TAG_REGEX =
/<[^>]*>/
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(src:, version: "", commit: "", out: "tdlib.json") ⇒ SchemaBuilder
constructor
A new instance of SchemaBuilder.
Constructor Details
#initialize(src:, version: "", commit: "", out: "tdlib.json") ⇒ SchemaBuilder
Returns a new instance of SchemaBuilder.
15 16 17 18 19 20 |
# File 'lib/gruubY/tdlib/schema_builder.rb', line 15 def initialize(src:, version: "", commit: "", out: "tdlib.json") @src = src @version = version @commit = commit @out = out end |
Instance Method Details
#call ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/gruubY/tdlib/schema_builder.rb', line 22 def call data = if @src.start_with?("http://", "https://") fetch_and_parse_tl(@src) else parse_tl_from_file(@src) end data["version"] = @version data["commit"] = @commit begin data["options"] = rescue StandardError => e warn "Warning: failed to fetch options: #{e.}" end save_json(data, @out) end |