Class: TFClient::TFPrompt

Inherits:
Object
  • Object
show all
Defined in:
lib/textflight-client/tfprompt.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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

Parameters:

  • value

    the value to set the attribute mass to.



8
9
10
# File 'lib/textflight-client/tfprompt.rb', line 8

def mass=(value)
  @mass = value
end

#operatorObject (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

Parameters:

  • value

    the value to set the attribute shield_charge to.



8
9
10
# File 'lib/textflight-client/tfprompt.rb', line 8

def shield_charge=(value)
  @shield_charge = value
end

#status_reportObject (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

Parameters:

  • value

    the value to set the attribute warp_charge to.



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

Parameters:

  • value

    the value to set the attribute x to.



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

Parameters:

  • value

    the value to set the attribute y to.



8
9
10
# File 'lib/textflight-client/tfprompt.rb', line 8

def y=(value)
  @y = value
end

Instance Method Details

#shield_percentObject



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_sObject



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_percentObject



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