Class: HelloComputed::Contact
- Inherits:
-
Object
- Object
- HelloComputed::Contact
- Defined in:
- lib/glimmer-dsl-opal/samples/hello/hello_computed.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.
26 27 28 29 30 |
# File 'lib/glimmer-dsl-opal/samples/hello/hello_computed.rb', line 26 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.
24 25 26 |
# File 'lib/glimmer-dsl-opal/samples/hello/hello_computed.rb', line 24 def first_name @first_name end |
#last_name ⇒ Object
Returns the value of attribute last_name.
24 25 26 |
# File 'lib/glimmer-dsl-opal/samples/hello/hello_computed.rb', line 24 def last_name @last_name end |
#year_of_birth ⇒ Object
Returns the value of attribute year_of_birth.
24 25 26 |
# File 'lib/glimmer-dsl-opal/samples/hello/hello_computed.rb', line 24 def year_of_birth @year_of_birth end |
Instance Method Details
#age ⇒ Object
36 37 38 39 40 |
# File 'lib/glimmer-dsl-opal/samples/hello/hello_computed.rb', line 36 def age Time.now.year - year_of_birth.to_i rescue 0 end |
#name ⇒ Object
32 33 34 |
# File 'lib/glimmer-dsl-opal/samples/hello/hello_computed.rb', line 32 def name "#{last_name}, #{first_name}" end |