Class: Diaspora::Cluster::Creator::Attribute

Inherits:
Object
  • Object
show all
Defined in:
lib/diaspora-cluster-creator/attribute.rb

Direct Known Subclasses

NodeAttribute

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#nameObject (readonly)

Returns the value of attribute name.



5
6
7
# File 'lib/diaspora-cluster-creator/attribute.rb', line 5

def name
  @name
end

#prefixObject (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

#labelObject



23
24
25
# File 'lib/diaspora-cluster-creator/attribute.rb', line 23

def label
  prefix
end

#to_sObject



15
16
17
# File 'lib/diaspora-cluster-creator/attribute.rb', line 15

def to_s
  name
end

#to_symObject



19
20
21
# File 'lib/diaspora-cluster-creator/attribute.rb', line 19

def to_sym
  name.to_s.gsub(/\W+/,'_').downcase.to_sym
end