Class: ShipBuilder

Inherits:
Object
  • Object
show all
Includes:
Blueprints
Defined in:
lib/uss-enterprise/ship_builders.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(type = nil) ⇒ ShipBuilder

Returns a new instance of ShipBuilder.



8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/uss-enterprise/ship_builders.rb', line 8

def initialize(type = nil)
  case type
  when nil
    @available_blueprints = Blueprints.new.gimme
  when 'SeaShip'
    @available_blueprints = SeaShipBlueprints.new.gimme
  when 'OrbitalShip'
    @available_blueprints = OrbitalShipBlueprints.new.gimme
  when 'StarShip'
    @available_blueprints = StarShipBlueprints.new.gimme
  end
end

Instance Attribute Details

#available_blueprintsObject (readonly)

Returns the value of attribute available_blueprints.



6
7
8
# File 'lib/uss-enterprise/ship_builders.rb', line 6

def available_blueprints
  @available_blueprints
end

#blueprintObject (readonly)

Returns the value of attribute blueprint.



6
7
8
# File 'lib/uss-enterprise/ship_builders.rb', line 6

def blueprint
  @blueprint
end

Instance Method Details

#build_itObject



25
26
27
# File 'lib/uss-enterprise/ship_builders.rb', line 25

def build_it
  puts @blueprint
end

#define_blueprint(type) ⇒ Object



21
22
23
# File 'lib/uss-enterprise/ship_builders.rb', line 21

def define_blueprint(type)
  @blueprint = @available_blueprints[type]
end