Class: WeighflowCli::OrderHandler::Handlers::OrderIndexResult

Inherits:
Object
  • Object
show all
Defined in:
lib/weighflow_cli/order_handler.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(index:, checksum:, file_name:) ⇒ OrderIndexResult

Returns a new instance of OrderIndexResult.



165
166
167
168
169
# File 'lib/weighflow_cli/order_handler.rb', line 165

def initialize(index:, checksum:, file_name:)
  @index = index
  @checksum = checksum
  @file_name = file_name
end

Instance Attribute Details

#checksumObject (readonly)

Returns the value of attribute checksum.



163
164
165
# File 'lib/weighflow_cli/order_handler.rb', line 163

def checksum
  @checksum
end

#file_nameObject (readonly)

Returns the value of attribute file_name.



163
164
165
# File 'lib/weighflow_cli/order_handler.rb', line 163

def file_name
  @file_name
end

#indexObject (readonly)

Returns the value of attribute index.



163
164
165
# File 'lib/weighflow_cli/order_handler.rb', line 163

def index
  @index
end

Instance Method Details

#dataObject



172
173
174
175
176
177
# File 'lib/weighflow_cli/order_handler.rb', line 172

def data
  return @data if defined?(@data)
  return {} unless @file_name       
  return {} unless File.exists?(@file_name)
  @data = JSON.parse(File.read(@file_name), symbolize_names: true)
end

#delete!Object



179
180
181
# File 'lib/weighflow_cli/order_handler.rb', line 179

def delete! 
  File.delete(@file_name) if File.exists?(@file_name)
end