Class: ConstStricter::ConstName
- Inherits:
-
Object
- Object
- ConstStricter::ConstName
- Defined in:
- lib/const_stricter/const_name.rb
Instance Attribute Summary collapse
-
#dynamic ⇒ Object
readonly
Returns the value of attribute dynamic.
Class Method Summary collapse
Instance Method Summary collapse
- #empty? ⇒ Boolean
- #full_name ⇒ Object
-
#initialize(name_parts = []) ⇒ ConstName
constructor
rubocop:disable Gp/OptArgParameters.
- #inspect ⇒ Object
- #line_no ⇒ Object
- #parent ⇒ Object
- #pop ⇒ Object
- #unshift(name_part) ⇒ Object
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
#dynamic ⇒ Object (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
37 |
# File 'lib/const_stricter/const_name.rb', line 37 def empty? = name_parts.empty? |
#full_name ⇒ Object
33 34 35 |
# File 'lib/const_stricter/const_name.rb', line 33 def full_name name_parts.join(MODULE_DELIMITER) unless empty? end |
#inspect ⇒ Object
11 |
# File 'lib/const_stricter/const_name.rb', line 11 def inspect = "#{full_name} :#{line_no}" |
#line_no ⇒ Object
13 14 15 |
# File 'lib/const_stricter/const_name.rb', line 13 def line_no @line_no ||= name_parts[0].line_no end |
#parent ⇒ Object
17 |
# File 'lib/const_stricter/const_name.rb', line 17 def parent = name_parts[0] |
#pop ⇒ Object
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 |