class Pixela::Pixel

Attributes

client[R]

@!attribute [r] client @return [Pixela::Client]

date[R]

@!attribute [r] date @return [Date]

graph_id[R]

@!attribute [r] graph_id @return [String]

Public Class Methods

new(client:, graph_id:, date:) click to toggle source

@param client [Pixela::Client] @param graph_id [String] @param date [Date,Time]

# File lib/pixela/pixel.rb, line 18
def initialize(client:, graph_id:, date:)
  @client   = client
  @graph_id = graph_id
  @date     = date
end

Public Instance Methods

create(quantity:, optional_data: nil) click to toggle source

It records the quantity of the specified date as a “Pixel”.

@param quantity [Integer,Float] @param optional_data [Object] Additional information other than quantity

@return [Pixela::Response]

@raise [Pixela::PixelaError] API is failed

@see docs.pixe.la/entry/post-pixel

@example

client.graph("test-graph").pixel(Date.new(2018, 9, 15)).create(quantity: 5, optional_data: {key: "value"})
# File lib/pixela/pixel.rb, line 37
def create(quantity:, optional_data: nil)
  client.create_pixel(graph_id: graph_id, date: date, quantity: quantity, optional_data: optional_data)
end
delete() click to toggle source

Delete the registered “Pixel”.

@return [Pixela::Response]

@raise [Pixela::PixelaError] API is failed

@see docs.pixe.la/entry/delete-pixel

@example

client.graph("test-graph").pixel(Date.new(2018, 9, 15)).delete
# File lib/pixela/pixel.rb, line 82
def delete
  client.delete_pixel(graph_id: graph_id, date: date)
end
get() click to toggle source

Get registered quantity as “Pixel”.

@return [Pixela::Response]

@raise [Pixela::PixelaError] API is failed

@see docs.pixe.la/entry/get-pixel

@example

client.graph("test-graph").pixel(Date.new(2018, 9, 15)).get
# File lib/pixela/pixel.rb, line 51
def get
  client.get_pixel(graph_id: graph_id, date: date)
end
update(quantity:, optional_data: nil) click to toggle source

Update the quantity already registered as a “Pixel”.

@param quantity [Integer,Float] @param optional_data [Object] Additional information other than quantity

@return [Pixela::Response]

@raise [Pixela::PixelaError] API is failed

@see docs.pixe.la/entry/put-pixel

@example

client.graph("test-graph").pixel(Date.new(2018, 9, 15)).update(quantity: 7, optional_data: {key: "value"})
# File lib/pixela/pixel.rb, line 68
def update(quantity:, optional_data: nil)
  client.update_pixel(graph_id: graph_id, date: date, quantity: quantity, optional_data: optional_data)
end