Class: Humanizer::Human
- Inherits:
-
Object
show all
- Defined in:
- lib/humanizer.rb
Class Method Summary
collapse
Instance Method Summary
collapse
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(name, *args) ⇒ Object
87
88
89
|
# File 'lib/humanizer.rb', line 87
def method_missing(name, *args)
args[0]
end
|
Class Method Details
.from(value) ⇒ Object
64
65
66
67
68
69
|
# File 'lib/humanizer.rb', line 64
def self.from(value)
type = value.class.to_s.downcase
human = Human.new
human.send "from_#{type}", value
end
|
Instance Method Details
#from_array(value) ⇒ Object
71
72
73
74
75
|
# File 'lib/humanizer.rb', line 71
def from_array(value)
value = Array(value)
value.join "#{Humanizer.config.array_delimeter} "
end
|
#from_hash(value) ⇒ Object
77
78
79
80
81
82
83
84
85
|
# File 'lib/humanizer.rb', line 77
def from_hash(value)
value = Hash(value)
value = value.map do |k, v|
"#{k}#{Humanizer.config.key_val_delimeter} #{v}"
end
value.join("#{Humanizer.config.hash_delimeter} ")
end
|