Class: TFClient::Models::Asteroids
- Defined in:
- lib/textflight-client/models/nav.rb
Instance Attribute Summary collapse
-
#density ⇒ Object
readonly
Returns the value of attribute density.
-
#ore ⇒ Object
readonly
Returns the value of attribute ore.
-
#percent ⇒ Object
readonly
Returns the value of attribute percent.
Attributes inherited from Model
#label, #translation, #values_hash
Instance Method Summary collapse
-
#initialize(line:) ⇒ Asteroids
constructor
A new instance of Asteroids.
- #to_s ⇒ Object
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
#density ⇒ Object (readonly)
Returns the value of attribute density.
143 144 145 |
# File 'lib/textflight-client/models/nav.rb', line 143 def density @density end |
#ore ⇒ Object (readonly)
Returns the value of attribute ore.
143 144 145 |
# File 'lib/textflight-client/models/nav.rb', line 143 def ore @ore end |
#percent ⇒ Object (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_s ⇒ Object
152 153 154 |
# File 'lib/textflight-client/models/nav.rb', line 152 def to_s %Q[#{@translation}: #{@ore} (#{@density}) => #{@percent}%] end |