Class: Diaspora::Cluster::Creator::Attribute
- Inherits:
-
Object
- Object
- Diaspora::Cluster::Creator::Attribute
- Defined in:
- lib/diaspora-cluster-creator/attribute.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#prefix ⇒ Object
readonly
Returns the value of attribute prefix.
Instance Method Summary collapse
-
#initialize(name) ⇒ Attribute
constructor
A new instance of Attribute.
- #label ⇒ Object
- #to_s ⇒ Object
- #to_sym ⇒ Object
Constructor Details
#initialize(name) ⇒ Attribute
Returns a new instance of Attribute.
6 7 8 9 10 11 12 13 |
# File 'lib/diaspora-cluster-creator/attribute.rb', line 6 def initialize(name) if /\((?<extracted_prefix>\w)\)/ =~ name @prefix = extracted_prefix.upcase else @prefix = name.slice(0).upcase end @name = name.gsub(/[\(\)]/,'') end |
Instance Attribute Details
#name ⇒ Object (readonly)
Returns the value of attribute name.
5 6 7 |
# File 'lib/diaspora-cluster-creator/attribute.rb', line 5 def name @name end |
#prefix ⇒ Object (readonly)
Returns the value of attribute prefix.
5 6 7 |
# File 'lib/diaspora-cluster-creator/attribute.rb', line 5 def prefix @prefix end |
Instance Method Details
#label ⇒ Object
23 24 25 |
# File 'lib/diaspora-cluster-creator/attribute.rb', line 23 def label prefix end |
#to_s ⇒ Object
15 16 17 |
# File 'lib/diaspora-cluster-creator/attribute.rb', line 15 def to_s name end |
#to_sym ⇒ Object
19 20 21 |
# File 'lib/diaspora-cluster-creator/attribute.rb', line 19 def to_sym name.to_s.gsub(/\W+/,'_').downcase.to_sym end |