Class: HumanValue::Humanization

Inherits:
Object
  • Object
show all
Defined in:
lib/human_value/humanization.rb

Instance Method Summary collapse

Constructor Details

#initialize(type) ⇒ Humanization

Returns a new instance of Humanization.



3
4
5
# File 'lib/human_value/humanization.rb', line 3

def initialize(type)
  @type
end

Instance Method Details

#call(value) ⇒ Object



11
12
13
# File 'lib/human_value/humanization.rb', line 11

def call(value)
  @coerce.call(value)
end

#coerce(&block) ⇒ Object



20
21
22
23
# File 'lib/human_value/humanization.rb', line 20

def coerce(&block)
  @coerce = block
  self
end

#matches?(value) ⇒ Boolean

Returns:

  • (Boolean)


7
8
9
# File 'lib/human_value/humanization.rb', line 7

def matches?(value)
  @test.call(value)
end

#test(&block) ⇒ Object



15
16
17
18
# File 'lib/human_value/humanization.rb', line 15

def test(&block)
  @test = block
  self
end