Class: RBS::Location::WithChildren
Relationships & Source Files | |
Super Chains via Extension / Inclusion / Inheritance | |
Class Chain:
self,
::RBS::Location
|
|
Instance Chain:
self,
::RBS::Location
|
|
Inherits: |
RBS::Location
|
Defined in: | lib/rbs/location.rb |
Class Method Summary
::RBS::Location
- Inherited
Instance Attribute Summary
- #optional_children readonly
- #required_children readonly
::RBS::Location
- Inherited
Instance Method Summary
::RBS::Location
- Inherited
#+, #<<, #==, #concat, #end_column, #end_line, #end_loc, #inspect, #name, #pred?, #range, #source, #start_column, #start_line, #start_loc, #to_json, #to_s, #with_children |
Constructor Details
.new(buffer:, start_pos:, end_pos:) ⇒ WithChildren
Instance Attribute Details
#optional_children (readonly)
[ GitHub ]# File 'lib/rbs/location.rb', line 148
attr_reader :required_children, :optional_children
#required_children (readonly)
[ GitHub ]# File 'lib/rbs/location.rb', line 148
attr_reader :required_children, :optional_children
Instance Method Details
#[](key)
[ GitHub ]# File 'lib/rbs/location.rb', line 163
def [](key) case when required_children.key?(_ = key) range = required_children[_ = key] Location.new(buffer: buffer, start_pos: range.begin, end_pos: range.end) when optional_children.key?(_ = key) range = required_children[_ = key] || optional_children[_ = key] if range Location.new(buffer: buffer, start_pos: range.begin, end_pos: range.end) end else raise "Unknown key given: `#{key}`" end end
#initialize_copy(from)
[ GitHub ]# File 'lib/rbs/location.rb', line 157
def initialize_copy(from) required_children.merge!(from.required_children) optional_children.merge!(from.optional_children) self end
#merge_optional(hash)
[ GitHub ]# File 'lib/rbs/location.rb', line 197
def merge_optional(hash) this = dup h = hash.transform_values do |value| case value when Range value when Location value.range else nil end end this.optional_children.merge!(h) this end
#merge_required(hash)
[ GitHub ]# File 'lib/rbs/location.rb', line 178
def merge_required(hash) this = dup h = hash.transform_values do |value| case value when Range value when Location value.range else raise end end this.required_children.merge!(h) this end