Class: Rubrowser::Parser::Definition::Base

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

Direct Known Subclasses

Class, Module

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

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

Returns a new instance of Base.



7
8
9
10
11
12
13
# File 'lib/rubrowser/parser/definition/base.rb', line 7

def initialize(namespace, file: nil, line: nil, lines: 0)
  @namespace = Array(namespace)
  @file = file
  @line = line
  @lines = lines
  @circular = false
end

Instance Attribute Details

#fileObject (readonly)

Returns the value of attribute file.



5
6
7
# File 'lib/rubrowser/parser/definition/base.rb', line 5

def file
  @file
end

#lineObject (readonly)

Returns the value of attribute line.



5
6
7
# File 'lib/rubrowser/parser/definition/base.rb', line 5

def line
  @line
end

#linesObject (readonly)

Returns the value of attribute lines.



5
6
7
# File 'lib/rubrowser/parser/definition/base.rb', line 5

def lines
  @lines
end

#namespaceObject (readonly)

Returns the value of attribute namespace.



5
6
7
# File 'lib/rubrowser/parser/definition/base.rb', line 5

def namespace
  @namespace
end

Instance Method Details

#<=>(other) ⇒ Object



39
40
41
# File 'lib/rubrowser/parser/definition/base.rb', line 39

def <=>(other)
  to_s <=> other.to_s
end

#==(other) ⇒ Object



35
36
37
# File 'lib/rubrowser/parser/definition/base.rb', line 35

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

#circular?Boolean

Returns:

  • (Boolean)


27
28
29
# File 'lib/rubrowser/parser/definition/base.rb', line 27

def circular?
  @circular
end

#kernel?Boolean

Returns:

  • (Boolean)


23
24
25
# File 'lib/rubrowser/parser/definition/base.rb', line 23

def kernel?
  namespace.empty?
end

#nameObject



15
16
17
# File 'lib/rubrowser/parser/definition/base.rb', line 15

def name
  namespace.last
end

#parentObject



19
20
21
# File 'lib/rubrowser/parser/definition/base.rb', line 19

def parent
  new(namespace[0...-1])
end

#set_circularObject



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

def set_circular
  @circular = true
end

#to_sObject



43
44
45
# File 'lib/rubrowser/parser/definition/base.rb', line 43

def to_s
  namespace.join('::')
end