Class: Lilac::CLI::ComponentName
- Inherits:
-
Object
- Object
- Lilac::CLI::ComponentName
- Defined in:
- lib/lilac/cli/build/component_name.rb
Overview
Value object for a .lil component's kebab-case name. Holds the
raw string and exposes the derived forms the build pipeline
needs:
name = ComponentName.new("admin--user-card")
name.ruby_class # => "Admin::UserCard"
name.to_s # => "admin--user-card"
-- separates namespace segments, - separates words within a
segment. Empty segments (leading/trailing --, double - between
words) raise at construction so misnamed files fail loudly rather
than emitting ::Foo / Foo:: downstream.
Instance Attribute Summary collapse
-
#kebab ⇒ Object
readonly
Returns the value of attribute kebab.
Instance Method Summary collapse
- #==(other) ⇒ Object (also: #eql?)
- #hash ⇒ Object
-
#initialize(kebab) ⇒ ComponentName
constructor
A new instance of ComponentName.
- #ruby_class ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(kebab) ⇒ ComponentName
Returns a new instance of ComponentName.
20 21 22 23 |
# File 'lib/lilac/cli/build/component_name.rb', line 20 def initialize(kebab) @kebab = kebab.to_s @ruby_class = build_ruby_class end |
Instance Attribute Details
#kebab ⇒ Object (readonly)
Returns the value of attribute kebab.
18 19 20 |
# File 'lib/lilac/cli/build/component_name.rb', line 18 def kebab @kebab end |
Instance Method Details
#==(other) ⇒ Object Also known as: eql?
33 34 35 |
# File 'lib/lilac/cli/build/component_name.rb', line 33 def ==(other) other.is_a?(ComponentName) && other.kebab == @kebab end |
#hash ⇒ Object
38 39 40 |
# File 'lib/lilac/cli/build/component_name.rb', line 38 def hash @kebab.hash end |
#ruby_class ⇒ Object
25 26 27 |
# File 'lib/lilac/cli/build/component_name.rb', line 25 def ruby_class @ruby_class end |
#to_s ⇒ Object
29 30 31 |
# File 'lib/lilac/cli/build/component_name.rb', line 29 def to_s @kebab end |