Class: Pixela::Pixel

Inherits:
Object
  • Object
show all
Defined in:
lib/pixela/pixel.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(client:, graph_id:, date:) ⇒ Pixel

Returns a new instance of Pixel.

Parameters:



18
19
20
21
22
# File 'lib/pixela/pixel.rb', line 18

def initialize(client:, graph_id:, date:)
  @client   = client
  @graph_id = graph_id
  @date     = date
end

Instance Attribute Details

#clientPixela::Client (readonly)

Returns:



5
6
7
# File 'lib/pixela/pixel.rb', line 5

def client
  @client
end

#dateDate (readonly)

Returns:

  • (Date)


13
14
15
# File 'lib/pixela/pixel.rb', line 13

def date
  @date
end

#graph_idString (readonly)

Returns:

  • (String)


9
10
11
# File 'lib/pixela/pixel.rb', line 9

def graph_id
  @graph_id
end

Instance Method Details

#create(quantity:) ⇒ Hashie::Mash

It records the quantity of the specified date as a "Pixel".

Examples:

client.graph("test-graph").pixel(Date.new(2018, 9, 15)).create(quantity: 5)

Parameters:

  • quantity (Integer, Float)

Returns:

  • (Hashie::Mash)

Raises:

See Also:



36
37
38
# File 'lib/pixela/pixel.rb', line 36

def create(quantity:)
  client.create_pixel(graph_id: graph_id, date: date, quantity: quantity)
end

#deleteHashie::Mash

Delete the registered "Pixel".

Examples:

client.graph("test-graph").pixel(Date.new(2018, 9, 15)).delete

Returns:

  • (Hashie::Mash)

Raises:

See Also:



80
81
82
# File 'lib/pixela/pixel.rb', line 80

def delete
  client.delete_pixel(graph_id: graph_id, date: date)
end

#getHashie::Mash

Get registered quantity as "Pixel".

Examples:

client.graph("test-graph").pixel(Date.new(2018, 9, 15)).get

Returns:

  • (Hashie::Mash)

Raises:

See Also:



50
51
52
# File 'lib/pixela/pixel.rb', line 50

def get
  client.get_pixel(graph_id: graph_id, date: date)
end

#update(quantity:) ⇒ Hashie::Mash

Update the quantity already registered as a "Pixel".

Examples:

client.graph("test-graph").pixel(Date.new(2018, 9, 15)).update(quantity: 7)

Parameters:

  • quantity (Integer, Float)

Returns:

  • (Hashie::Mash)

Raises:

See Also:



66
67
68
# File 'lib/pixela/pixel.rb', line 66

def update(quantity:)
  client.update_pixel(graph_id: graph_id, date: date, quantity: quantity)
end