Class: Rubrowser::Parser::Relation::Base
- Inherits:
-
Object
- Object
- Rubrowser::Parser::Relation::Base
- Defined in:
- lib/rubrowser/parser/relation/base.rb
Instance Attribute Summary collapse
-
#file ⇒ Object
readonly
Returns the value of attribute file.
-
#line ⇒ Object
readonly
Returns the value of attribute line.
Instance Method Summary collapse
- #==(other) ⇒ Object
- #caller_namespace ⇒ Object
- #circular? ⇒ Boolean
-
#initialize(namespace, caller_namespace, file: nil, line: nil) ⇒ Base
constructor
A new instance of Base.
- #namespace ⇒ Object
- #resolve(definitions) ⇒ Object
- #set_circular ⇒ Object
Constructor Details
#initialize(namespace, caller_namespace, file: nil, line: nil) ⇒ Base
Returns a new instance of Base.
9 10 11 12 13 14 15 |
# File 'lib/rubrowser/parser/relation/base.rb', line 9 def initialize(namespace, caller_namespace, file: nil, line: nil) @namespace = namespace @caller_namespace = caller_namespace @file = file @line = line @is_circular = false end |
Instance Attribute Details
#file ⇒ Object (readonly)
Returns the value of attribute file.
7 8 9 |
# File 'lib/rubrowser/parser/relation/base.rb', line 7 def file @file end |
#line ⇒ Object (readonly)
Returns the value of attribute line.
7 8 9 |
# File 'lib/rubrowser/parser/relation/base.rb', line 7 def line @line end |
Instance Method Details
#==(other) ⇒ Object
39 40 41 42 43 |
# File 'lib/rubrowser/parser/relation/base.rb', line 39 def ==(other) namespace == other.namespace && caller_namespace == other.caller_namespace && circular? == other.circular? end |
#caller_namespace ⇒ Object
21 22 23 |
# File 'lib/rubrowser/parser/relation/base.rb', line 21 def caller_namespace Definition::Base.new(@caller_namespace, file: file, line: line) end |
#circular? ⇒ Boolean
25 26 27 |
# File 'lib/rubrowser/parser/relation/base.rb', line 25 def circular? @is_circular end |
#namespace ⇒ Object
17 18 19 |
# File 'lib/rubrowser/parser/relation/base.rb', line 17 def namespace Definition::Base.new(@namespace, file: file, line: line) end |
#resolve(definitions) ⇒ Object
33 34 35 36 37 |
# File 'lib/rubrowser/parser/relation/base.rb', line 33 def resolve(definitions) possibilities.find do |possibility| !definitions.bsearch { |definition| definition <=> possibility }.nil? end || possibilities.last end |
#set_circular ⇒ Object
29 30 31 |
# File 'lib/rubrowser/parser/relation/base.rb', line 29 def set_circular @is_circular = true end |