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
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

#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

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_namespaceObject



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

Returns:

  • (Boolean)


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

def circular?
  @is_circular
end

#namespaceObject



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_circularObject



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

def set_circular
  @is_circular = true
end