Class: HelloComputed::Contact

Inherits:
Object
  • Object
show all
Defined in:
lib/glimmer-dsl-opal/samples/hello/hello_computed.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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_nameObject

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_nameObject

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_birthObject

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

#ageObject



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

#nameObject



32
33
34
# File 'lib/glimmer-dsl-opal/samples/hello/hello_computed.rb', line 32

def name
  "#{last_name}, #{first_name}"
end