Class: JPLMissions::Mission
- Inherits:
-
Object
- Object
- JPLMissions::Mission
- Defined in:
- lib/jpl_missions/Mission.rb
Constant Summary collapse
- @@all =
[]
Instance Attribute Summary collapse
-
#description ⇒ Object
Returns the value of attribute description.
-
#details ⇒ Object
Returns the value of attribute details.
-
#launch_date ⇒ Object
Returns the value of attribute launch_date.
-
#title ⇒ Object
Returns the value of attribute title.
Class Method Summary collapse
- .all ⇒ Object
- .clear_all ⇒ Object
- .create_missions_from_array(array) ⇒ Object
- .find_from_user_input(input) ⇒ Object
Instance Method Summary collapse
-
#initialize(title) ⇒ Mission
constructor
A new instance of Mission.
- #save ⇒ Object
Constructor Details
#initialize(title) ⇒ Mission
Returns a new instance of Mission.
5 6 7 8 |
# File 'lib/jpl_missions/Mission.rb', line 5 def initialize(title) self.title = title save end |
Instance Attribute Details
#description ⇒ Object
Returns the value of attribute description.
2 3 4 |
# File 'lib/jpl_missions/Mission.rb', line 2 def description @description end |
#details ⇒ Object
Returns the value of attribute details.
2 3 4 |
# File 'lib/jpl_missions/Mission.rb', line 2 def details @details end |
#launch_date ⇒ Object
Returns the value of attribute launch_date.
2 3 4 |
# File 'lib/jpl_missions/Mission.rb', line 2 def launch_date @launch_date end |
#title ⇒ Object
Returns the value of attribute title.
2 3 4 |
# File 'lib/jpl_missions/Mission.rb', line 2 def title @title end |
Class Method Details
.all ⇒ Object
26 27 28 |
# File 'lib/jpl_missions/Mission.rb', line 26 def self.all @@all end |
.clear_all ⇒ Object
30 31 32 |
# File 'lib/jpl_missions/Mission.rb', line 30 def self.clear_all @@all.clear end |
.create_missions_from_array(array) ⇒ Object
10 11 12 13 14 15 16 |
# File 'lib/jpl_missions/Mission.rb', line 10 def self.create_missions_from_array(array) array.each do |mission_hash| new_mission = self.new(mission_hash[:title]) new_mission.launch_date = mission_hash[:launch_date] new_mission.description = mission_hash[:description] end end |
.find_from_user_input(input) ⇒ Object
18 19 20 |
# File 'lib/jpl_missions/Mission.rb', line 18 def self.find_from_user_input(input) self.all[input.to_i - 1] end |
Instance Method Details
#save ⇒ Object
22 23 24 |
# File 'lib/jpl_missions/Mission.rb', line 22 def save @@all << self end |