Class: Omelettes::Column

Inherits:
Object
  • Object
show all
Defined in:
lib/omelettes/column.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, style = nil, &block) ⇒ Column

Returns a new instance of Column.



6
7
8
9
10
# File 'lib/omelettes/column.rb', line 6

def initialize(name, style=nil, &block)
  @name = name
  @style = style
  @custom_block = block
end

Instance Attribute Details

#custom_blockObject

Returns the value of attribute custom_block.



5
6
7
# File 'lib/omelettes/column.rb', line 5

def custom_block
  @custom_block
end

#nameObject

Returns the value of attribute name.



5
6
7
# File 'lib/omelettes/column.rb', line 5

def name
  @name
end

#styleObject

Returns the value of attribute style.



5
6
7
# File 'lib/omelettes/column.rb', line 5

def style
  @style
end

Class Method Details

.default(name, value) ⇒ Object



20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'lib/omelettes/column.rb', line 20

def self.default(name, value)
  name = name.to_s.downcase.to_sym
  case name
  when :hardened
    return value
  when :first_name, :last_name
    return Faker::Name.send(name)
  when :city, :state, :country, :street_address, :street_name, :zip_code
    return Faker::Address.send(name)
  when :company_name, :company
    return Faker::Company.name
  when :email, :user_name
    return Faker::Internet.send(name)
  when :paragraph, :paragraphs, :sentence, :sentences, :words
    return Faker::Lorem.send(name)
  when :phone, :contact_phone, :fax
    return Faker::PhoneNumber.phone_number
  when :url, :website
    return Faker::Internet.domain_name
  else
    return Omelettes::Obfuscate.obfuscate(value)
  end
end

Instance Method Details

#as(style) ⇒ Object Also known as: like



44
45
46
47
# File 'lib/omelettes/column.rb', line 44

def as(style)
  @style = style unless @style == :hardened
  self
end

#process(string) ⇒ Object



12
13
14
15
16
17
18
# File 'lib/omelettes/column.rb', line 12

def process(string)
  if @custom_block
    return @custom_block.call(string)
  else
    Column.default(@style || @name, string)
  end
end