Class: TFClient::TFPrompt
- Inherits:
-
Object
- Object
- TFClient::TFPrompt
- Defined in:
- lib/textflight-client/tfprompt.rb
Instance Attribute Summary collapse
-
#mass ⇒ Object
writeonly
Sets the attribute mass.
-
#operator ⇒ Object
readonly
Returns the value of attribute operator.
-
#shield_charge ⇒ Object
writeonly
Sets the attribute shield_charge.
-
#status_report ⇒ Object
readonly
Returns the value of attribute status_report.
-
#warp_charge ⇒ Object
writeonly
Sets the attribute warp_charge.
-
#x ⇒ Object
writeonly
Sets the attribute x.
-
#y ⇒ Object
writeonly
Sets the attribute y.
Instance Method Summary collapse
-
#initialize(operator:, status_report:) ⇒ TFPrompt
constructor
A new instance of TFPrompt.
- #shield_percent ⇒ Object
- #to_s ⇒ Object
- #warp_percent ⇒ Object
Constructor Details
#initialize(operator:, status_report:) ⇒ TFPrompt
Returns a new instance of TFPrompt.
10 11 12 13 14 15 16 |
# File 'lib/textflight-client/tfprompt.rb', line 10 def initialize(operator:, status_report:) @operator = operator @status_report = status_report @mass = status_report.hash[:mass].to_i @warp_charge = status_report.hash[:warp_charge] @shield_charge = status_report.hash[:shield] end |
Instance Attribute Details
#mass=(value) ⇒ Object (writeonly)
Sets the attribute mass
8 9 10 |
# File 'lib/textflight-client/tfprompt.rb', line 8 def mass=(value) @mass = value end |
#operator ⇒ Object (readonly)
Returns the value of attribute operator.
7 8 9 |
# File 'lib/textflight-client/tfprompt.rb', line 7 def operator @operator end |
#shield_charge=(value) ⇒ Object (writeonly)
Sets the attribute shield_charge
8 9 10 |
# File 'lib/textflight-client/tfprompt.rb', line 8 def shield_charge=(value) @shield_charge = value end |
#status_report ⇒ Object (readonly)
Returns the value of attribute status_report.
5 6 7 |
# File 'lib/textflight-client/tfprompt.rb', line 5 def status_report @status_report end |
#warp_charge=(value) ⇒ Object (writeonly)
Sets the attribute warp_charge
8 9 10 |
# File 'lib/textflight-client/tfprompt.rb', line 8 def warp_charge=(value) @warp_charge = value end |
#x=(value) ⇒ Object (writeonly)
Sets the attribute x
8 9 10 |
# File 'lib/textflight-client/tfprompt.rb', line 8 def x=(value) @x = value end |
#y=(value) ⇒ Object (writeonly)
Sets the attribute y
8 9 10 |
# File 'lib/textflight-client/tfprompt.rb', line 8 def y=(value) @y = value end |
Instance Method Details
#shield_percent ⇒ Object
26 27 28 |
# File 'lib/textflight-client/tfprompt.rb', line 26 def shield_percent ((@shield_charge.to_f/@mass.to_i) * 100).to_i end |
#to_s ⇒ Object
18 19 20 |
# File 'lib/textflight-client/tfprompt.rb', line 18 def to_s "S: #{shield_percent}% Ms: #{@mass} Wrp: #{warp_percent}% (#{@x},#{@y}) #{operator} > " end |
#warp_percent ⇒ Object
22 23 24 |
# File 'lib/textflight-client/tfprompt.rb', line 22 def warp_percent ((@warp_charge.to_f/@mass.to_i) * 100).to_i end |