Class: Chronograph::Person
- Inherits:
-
Struct
- Object
- Struct
- Chronograph::Person
- Defined in:
- lib/chronograph/person.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#birth ⇒ Object
Returns the value of attribute birth.
-
#death ⇒ Object
Returns the value of attribute death.
-
#desc ⇒ Object
Returns the value of attribute desc.
-
#events ⇒ Object
Returns the value of attribute events.
-
#name ⇒ Object
Returns the value of attribute name.
Instance Method Summary collapse
- #begining_event ⇒ Object
- #ending_event ⇒ Object
-
#initialize(name, birth, death, desc, *events) ⇒ Person
constructor
A new instance of Person.
Constructor Details
#initialize(name, birth, death, desc, *events) ⇒ Person
Returns a new instance of Person.
4 5 6 7 8 9 10 11 12 13 14 15 |
# File 'lib/chronograph/person.rb', line 4 def initialize(name, birth, death, desc, *events) raise TypeError.new("name has to be a name or symbol") unless name.is_a?(String) || name.is_a?(Symbol) raise TypeError.new("birth and death must be a date") unless birth.is_a?(Date) && death.is_a?(Date) raise TypeError.new("desc must be a string") unless desc.is_a? String @name = name @birth = birth @death = death @desc = desc @events = events end |
Instance Attribute Details
#birth ⇒ Object
Returns the value of attribute birth
2 3 4 |
# File 'lib/chronograph/person.rb', line 2 def birth @birth end |
#death ⇒ Object
Returns the value of attribute death
2 3 4 |
# File 'lib/chronograph/person.rb', line 2 def death @death end |
#desc ⇒ Object
Returns the value of attribute desc
2 3 4 |
# File 'lib/chronograph/person.rb', line 2 def desc @desc end |
#events ⇒ Object
Returns the value of attribute events
2 3 4 |
# File 'lib/chronograph/person.rb', line 2 def events @events end |
#name ⇒ Object
Returns the value of attribute name
2 3 4 |
# File 'lib/chronograph/person.rb', line 2 def name @name end |