Class: HelloComputed::Contact

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

Instance Attribute Summary collapse

Instance Method Summary collapse

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_nameObject

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_nameObject

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_birthObject

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

#ageObject



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

#nameObject



11
12
13
# File 'lib/glimmer-dsl-opal/samples/hello/hello_computed/contact.rb', line 11

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