Class: TFClient::Models::Asteroids

Inherits:
Model
  • Object
show all
Defined in:
lib/textflight-client/models/nav.rb

Instance Attribute Summary collapse

Attributes inherited from Model

#label, #translation, #values_hash

Instance Method Summary collapse

Constructor Details

#initialize(line:) ⇒ Asteroids

Returns a new instance of Asteroids.



145
146
147
148
149
150
# File 'lib/textflight-client/models/nav.rb', line 145

def initialize(line:)
  super(line: line)
  @ore = @values_hash[:asteroid_type]
  @density = @values_hash[:asteroid_density].to_i
  @percent = ((@density/7.0) * 100).round
end

Instance Attribute Details

#densityObject (readonly)

Returns the value of attribute density.



143
144
145
# File 'lib/textflight-client/models/nav.rb', line 143

def density
  @density
end

#oreObject (readonly)

Returns the value of attribute ore.



143
144
145
# File 'lib/textflight-client/models/nav.rb', line 143

def ore
  @ore
end

#percentObject (readonly)

Returns the value of attribute percent.



143
144
145
# File 'lib/textflight-client/models/nav.rb', line 143

def percent
  @percent
end

Instance Method Details

#to_sObject



152
153
154
# File 'lib/textflight-client/models/nav.rb', line 152

def to_s
  %Q[#{@translation}: #{@ore} (#{@density}) => #{@percent}%]
end