Class: AdjectiveAnimal::AdjAni
- Inherits:
-
Object
- Object
- AdjectiveAnimal::AdjAni
- Defined in:
- lib/adjective_animal.rb
Constant Summary collapse
- FIELDS =
[:adjective, :animal, :full, :starts_with, :the]
Instance Method Summary collapse
- #adj ⇒ Object (also: #first_name)
- #ani ⇒ Object (also: #last_name)
- #generate_aa ⇒ Object
-
#initialize(options = {}) ⇒ AdjAni
constructor
A new instance of AdjAni.
- #to_s ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ AdjAni
Returns a new instance of AdjAni.
26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/adjective_animal.rb', line 26 def initialize(={}) if .is_a?(String) || .is_a?(Symbol) .length == 1 ? self.starts_with = .downcase.to_s : self.starts_with = nil end if .is_a?(Hash) sym_opts = symbolize_hash() #.map { |k, v| [k.to_sym, v] }.to_h if sym_opts.has_key?(:starts_with) sym_opts[:starts_with].length == 1 ? self.starts_with = sym_opts[:starts_with].downcase.to_sym : self.starts_with = nil end end generate_aa end |
Instance Method Details
#adj ⇒ Object Also known as: first_name
45 46 47 |
# File 'lib/adjective_animal.rb', line 45 def adj self.adjective end |
#ani ⇒ Object Also known as: last_name
51 52 53 |
# File 'lib/adjective_animal.rb', line 51 def ani self.animal end |
#generate_aa ⇒ Object
39 40 41 42 43 |
# File 'lib/adjective_animal.rb', line 39 def generate_aa self.adjective = AdjectiveAnimal::AdjAni.humanize(AdjectiveAnimal::AdjAni.get_adjective(self.starts_with)) self.animal = AdjectiveAnimal::AdjAni.humanize(AdjectiveAnimal::AdjAni.get_animal(self.starts_with)) self end |
#to_s ⇒ Object
57 58 59 |
# File 'lib/adjective_animal.rb', line 57 def to_s "#{self.adjective} #{self.animal}" end |