Class: HelloComputed::Contact
- Inherits:
-
Object
- Object
- HelloComputed::Contact
- Defined in:
- lib/glimmer-dsl-opal/samples/hello/hello_computed/contact.rb
Instance Attribute Summary collapse
-
#first_name ⇒ Object
Returns the value of attribute first_name.
-
#last_name ⇒ Object
Returns the value of attribute last_name.
-
#year_of_birth ⇒ Object
Returns the value of attribute year_of_birth.
Instance Method Summary collapse
- #age ⇒ Object
-
#initialize(attribute_map) ⇒ Contact
constructor
A new instance of Contact.
- #name ⇒ Object
Constructor Details
#initialize(attribute_map) ⇒ Contact
Returns a new instance of Contact.
5 6 7 8 9 |
# File 'lib/glimmer-dsl-opal/samples/hello/hello_computed/contact.rb', line 5 def initialize(attribute_map) @first_name = attribute_map[:first_name] @last_name = attribute_map[:last_name] @year_of_birth = attribute_map[:year_of_birth] end |
Instance Attribute Details
#first_name ⇒ Object
Returns the value of attribute first_name.
3 4 5 |
# File 'lib/glimmer-dsl-opal/samples/hello/hello_computed/contact.rb', line 3 def first_name @first_name end |
#last_name ⇒ Object
Returns the value of attribute last_name.
3 4 5 |
# File 'lib/glimmer-dsl-opal/samples/hello/hello_computed/contact.rb', line 3 def last_name @last_name end |
#year_of_birth ⇒ Object
Returns the value of attribute year_of_birth.
3 4 5 |
# File 'lib/glimmer-dsl-opal/samples/hello/hello_computed/contact.rb', line 3 def year_of_birth @year_of_birth end |
Instance Method Details
#age ⇒ Object
15 16 17 18 19 |
# File 'lib/glimmer-dsl-opal/samples/hello/hello_computed/contact.rb', line 15 def age Time.now.year - year_of_birth.to_i rescue 0 end |
#name ⇒ Object
11 12 13 |
# File 'lib/glimmer-dsl-opal/samples/hello/hello_computed/contact.rb', line 11 def name "#{last_name}, #{first_name}" end |