Class: Attribeautiful::Attribute::Name

Inherits:
Object
  • Object
show all
Defined in:
lib/attribeautiful/attribute/name.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name) ⇒ Name

Returns a new instance of Name.



7
8
9
10
# File 'lib/attribeautiful/attribute/name.rb', line 7

def initialize(name)
  self.text = name
  self.use_dashes
end

Instance Attribute Details

#textObject

Returns the value of attribute text.



5
6
7
# File 'lib/attribeautiful/attribute/name.rb', line 5

def text
  @text
end

Instance Method Details

#to_sObject



26
27
28
# File 'lib/attribeautiful/attribute/name.rb', line 26

def to_s
  use_dashes? ? text.gsub('_', '-') : text.gsub('-', '_')
end

#use_dashesObject



16
17
18
19
# File 'lib/attribeautiful/attribute/name.rb', line 16

def use_dashes
  @use_dashes = true
  self
end

#use_dashes?Boolean

Returns:

  • (Boolean)


12
13
14
# File 'lib/attribeautiful/attribute/name.rb', line 12

def use_dashes?
  @use_dashes
end

#use_underscoresObject



21
22
23
24
# File 'lib/attribeautiful/attribute/name.rb', line 21

def use_underscores
  @use_dashes = false
  self
end