Class: Hexx::CLI::Name
- Inherits:
-
Object
- Object
- Hexx::CLI::Name
- Defined in:
- lib/hexx/cli/name.rb
Overview
Decorates a string with conventional names
Class Method Summary collapse
-
.initialize(string) ⇒ Hexx::CLI::Name
Constructs the parser object.
Instance Method Summary collapse
-
#const ⇒ String
Returns the name as a last part of constant.
-
#file ⇒ String
Returns the dashes-delimited name.
-
#item ⇒ String
Returns the last part of the singular name.
-
#items ⇒ String
Returns the last part of the plural name.
-
#namespaces ⇒ Array<String>
Returns the array of namespaces (module names) for the constant.
-
#new(string) ⇒ Hexx::CLI::Name
Constructs the parser object.
-
#path ⇒ String
Returns the slash-delimited name.
-
#type ⇒ String
Returns the name as a full constant.
Class Method Details
.initialize(string) ⇒ Hexx::CLI::Name
Constructs the parser object
22 23 24 |
# File 'lib/hexx/cli/name.rb', line 22 def initialize(string) @list = string.to_s.snake_case.gsub(/\:{2}|-/, "/").split(".") end |
Instance Method Details
#const ⇒ String
Returns the name as a last part of constant
100 101 102 |
# File 'lib/hexx/cli/name.rb', line 100 def const @const ||= [camels.last, method].compact.join(".") end |
#file ⇒ String
Returns the dashes-delimited name
61 62 63 |
# File 'lib/hexx/cli/name.rb', line 61 def file @file ||= [snakes.join("-"), method].compact.join(".") end |
#item ⇒ String
Returns the last part of the singular name
35 36 37 |
# File 'lib/hexx/cli/name.rb', line 35 def item @item ||= snakes.last.to_s.singular end |
#items ⇒ String
Returns the last part of the plural name
48 49 50 |
# File 'lib/hexx/cli/name.rb', line 48 def items @items ||= item.plural end |
#namespaces ⇒ Array<String>
Returns the array of namespaces (module names) for the constant
113 114 115 |
# File 'lib/hexx/cli/name.rb', line 113 def namespaces @namespaces ||= camels[0..-2] end |
#new(string) ⇒ Hexx::CLI::Name
Constructs the parser object
22 23 24 |
# File 'lib/hexx/cli/name.rb', line 22 def initialize(string) @list = string.to_s.snake_case.gsub(/\:{2}|-/, "/").split(".") end |
#path ⇒ String
Returns the slash-delimited name
74 75 76 |
# File 'lib/hexx/cli/name.rb', line 74 def path @path ||= [snakes.join("/"), method].compact.join(".") end |
#type ⇒ String
Returns the name as a full constant
87 88 89 |
# File 'lib/hexx/cli/name.rb', line 87 def type @type ||= [camels.join("::"), method].compact.join(".") end |