Sha256: 725b19f64f3dc5dd26341ce1a49f4a0cbcdd6444b74b7b38d4b8b176c6b544d7

Contents?: true

Size: 1.18 KB

Versions: 1

Compression:

Stored size: 1.18 KB

Contents

module SPACEX
  class DragonCapsules < Hashie::Trash
    include Hashie::Extensions::IgnoreUndeclared

    property 'capsule_id', from: 'id'
    property 'name'
    property 'type'
    property 'active'
    property 'crew_capacity'
    property 'sidewall_angle_deg'
    property 'orbit_duration_yr'
    property 'dry_mass_kg'
    property 'dry_mass_lb'
    property 'first_flight'
    property 'heat_shield'
    property 'thrusters'
    property 'launch_payload_mass'
    property 'launch_payload_vol'
    property 'return_payload_mass'
    property 'return_payload_vol'
    property 'pressurized_capsule'
    property 'trunk'
    property 'height_w_trunk'
    property 'diameter'
    property 'flickr_images'
    property 'wikipedia'
    property 'description'

    class << self
      def retrieve_all
        data = SPACEX::BaseRequest.call_api('dragons')
        data.get.body.map { |k| SPACEX::DragonCapsules.new(k) }
      end

      def get(dragon_id = nil)
        return retrieve_all if dragon_id.nil?

        data = SPACEX::BaseRequest.get("dragons/#{dragon_id}")
        SPACEX::DragonCapsules.new(data)
      end

      def info(dragon_id = nil)
        get(dragon_id)
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
spacex-0.0.7 lib/spacex/dragon_capsules.rb