Class: ItemJsonGenerator

Inherits:
Object
  • Object
show all
Defined in:
app/generators/item_json_generator.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(item) ⇒ ItemJsonGenerator

Returns a new instance of ItemJsonGenerator


4
5
6
# File 'app/generators/item_json_generator.rb', line 4

def initialize(item)
  @item = item
end

Instance Attribute Details

#itemObject (readonly)

Returns the value of attribute item


2
3
4
# File 'app/generators/item_json_generator.rb', line 2

def item
  @item
end

Instance Method Details

#generateObject


8
9
10
11
12
13
14
15
16
17
# File 'app/generators/item_json_generator.rb', line 8

def generate
  {
    name: item.name,
    link_url: item.link_url,
    image_url: item.image_url,
    latest_price: item.latest_price,
    all_time_min_price_low: item.all_time_min_price_low,
    all_time_min_price_high: item.all_time_min_price_high
  }
end

#generate_dataObject


19
20
21
22
23
24
# File 'app/generators/item_json_generator.rb', line 19

def generate_data
  {
    name: item.name,
    data: item.all_stats_data
  }
end