Class: ConstStricter::ConstName

Inherits:
Object
  • Object
show all
Defined in:
lib/const_stricter/const_name.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name_parts = []) ⇒ ConstName

rubocop:disable Gp/OptArgParameters



6
7
8
9
# File 'lib/const_stricter/const_name.rb', line 6

def initialize(name_parts = []) # rubocop:disable Gp/OptArgParameters
  @name_parts = name_parts
  @dynamic = false
end

Instance Attribute Details

#dynamicObject (readonly)

Returns the value of attribute dynamic.



3
4
5
# File 'lib/const_stricter/const_name.rb', line 3

def dynamic
  @dynamic
end

Class Method Details

.split(string) ⇒ Object



29
30
31
# File 'lib/const_stricter/const_name.rb', line 29

def self.split(string)
  string.split(MODULE_DELIMITER)
end

Instance Method Details

#empty?Boolean

Returns:

  • (Boolean)


37
# File 'lib/const_stricter/const_name.rb', line 37

def empty? = name_parts.empty?

#full_nameObject



33
34
35
# File 'lib/const_stricter/const_name.rb', line 33

def full_name
  name_parts.join(MODULE_DELIMITER) unless empty?
end

#inspectObject



11
# File 'lib/const_stricter/const_name.rb', line 11

def inspect = "#{full_name} :#{line_no}"

#line_noObject



13
14
15
# File 'lib/const_stricter/const_name.rb', line 13

def line_no
  @line_no ||= name_parts[0].line_no
end

#parentObject



17
# File 'lib/const_stricter/const_name.rb', line 17

def parent = name_parts[0]

#popObject



24
# File 'lib/const_stricter/const_name.rb', line 24

def pop = name_parts.pop

#unshift(name_part) ⇒ Object



19
20
21
22
# File 'lib/const_stricter/const_name.rb', line 19

def unshift(name_part)
  @dynamic ||= name_part.dynamic
  name_parts.unshift name_part
end