Class: Rubrowser::Parser::Relation::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/rubrowser/parser/relation/base.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(namespace, caller_namespace, file: nil, line: nil) ⇒ Base

Returns a new instance of Base.



9
10
11
12
13
14
# 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
end

Instance Attribute Details

#caller_namespaceObject (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

#fileObject (readonly)

Returns the value of attribute file.



7
8
9
# File 'lib/rubrowser/parser/relation/base.rb', line 7

def file
  @file
end

#lineObject (readonly)

Returns the value of attribute line.



7
8
9
# File 'lib/rubrowser/parser/relation/base.rb', line 7

def line
  @line
end

#namespaceObject (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



30
31
32
33
# File 'lib/rubrowser/parser/relation/base.rb', line 30

def ==(other)
  namespace == other.namespace &&
    caller_namespace == other.caller_namespace
end

#resolve(definitions) ⇒ Object



24
25
26
27
28
# File 'lib/rubrowser/parser/relation/base.rb', line 24

def resolve(definitions)
  possibilities.find do |possibility|
    definitions.any? { |definition| definition == possibility }
  end || possibilities.last
end