Class: Rubrowser::Parser::Relation::Base
- Inherits:
-
Object
- Object
- Rubrowser::Parser::Relation::Base
- Defined in:
- lib/rubrowser/parser/relation/base.rb
Instance Attribute Summary collapse
-
#caller_namespace ⇒ Object
readonly
Returns the value of attribute caller_namespace.
-
#file ⇒ Object
readonly
Returns the value of attribute file.
-
#line ⇒ Object
readonly
Returns the value of attribute line.
-
#namespace ⇒ Object
readonly
Returns the value of attribute namespace.
Instance Method Summary collapse
- #==(other) ⇒ Object
- #circular? ⇒ Boolean
-
#initialize(namespace, caller_namespace, file: nil, line: nil) ⇒ Base
constructor
A new instance of Base.
- #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
#caller_namespace ⇒ Object (readonly)
Returns the value of attribute caller_namespace.
7 8 9 |
# File 'lib/rubrowser/parser/relation/base.rb', line 7 def caller_namespace @caller_namespace end |
#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 |
#namespace ⇒ Object (readonly)
Returns the value of attribute namespace.
7 8 9 |
# File 'lib/rubrowser/parser/relation/base.rb', line 7 def namespace @namespace 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 |
#circular? ⇒ Boolean
25 26 27 |
# File 'lib/rubrowser/parser/relation/base.rb', line 25 def circular? @is_circular 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 } 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 |