Class: Nova::Constructor
- Inherits:
-
Object
- Object
- Nova::Constructor
- Defined in:
- lib/nova/constructor.rb
Overview
Creates a star from a create call.
Instance Method Summary collapse
-
#data ⇒ Hash<Symbol, Object>
Returns information about the star, like the type, the required platforms, and what it’s named.
-
#initialize(options) { ... } ⇒ Constructor
constructor
Initialize the constructor.
-
#modify_or_create ⇒ Class
Modifies an already existing star if it exists, or creates it if it doesn’t.
Constructor Details
#initialize(options) { ... } ⇒ Constructor
Initialize the constructor.
17 18 19 20 |
# File 'lib/nova/constructor.rb', line 17 def initialize(, &block) @options = @block = block end |
Instance Method Details
#data ⇒ Hash<Symbol, Object>
Returns information about the star, like the type, the required platforms, and what it’s named.
45 46 47 48 49 50 |
# File 'lib/nova/constructor.rb', line 45 def data @_data ||= { :as => @options.values.first, :type => @options.keys.first } end |
#modify_or_create ⇒ Class
Modifies an already existing star if it exists, or creates it if it doesn’t.
27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/nova/constructor.rb', line 27 def modify_or_create star_type = Star.types[data[:type]] raise NoStarError, "Could not find star type #{data[:type]}." unless star_type if Star.stars[data[:type]][data[:as]] handle_existing else handle_new star_type end end |