Class: TFClient::Models::ModelWithItems

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

Direct Known Subclasses

Cargo, Links, Outfits, Planets, Structures

Instance Attribute Summary collapse

Attributes inherited from Model

#label, #translation, #values_hash

Instance Method Summary collapse

Methods inherited from Model

#initialize

Constructor Details

This class inherits a constructor from TFClient::Models::Model

Instance Attribute Details

#itemsObject (readonly)

Returns the value of attribute items.



32
33
34
# File 'lib/textflight-client/models/model.rb', line 32

def items
  @items
end

Instance Method Details

#countObject



34
35
36
# File 'lib/textflight-client/models/model.rb', line 34

def count
  @items.count
end

#items_to_sObject



42
43
44
# File 'lib/textflight-client/models/model.rb', line 42

def items_to_s
  @items.map { |item| "\t#{item[:string]}" }
end

#lines_offsetObject



50
51
52
# File 'lib/textflight-client/models/model.rb', line 50

def lines_offset
  @items.length + 1
end

#response_strObject



46
47
48
# File 'lib/textflight-client/models/model.rb', line 46

def response_str
  "#{@translation}:\n#{items_to_s.join("\n")}"
end

#to_sObject



38
39
40
# File 'lib/textflight-client/models/model.rb', line 38

def to_s
  "#{@translation}: #{@items.map { |item| item[:string]}}"
end