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:, optional_data: nil) ⇒ Pixela::Response

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, optional_data: {key: "value"})

Parameters:

  • quantity (Integer, Float)
  • optional_data (Object) (defaults to: nil)

    Additional information other than quantity

Returns:

Raises:

See Also:



37
38
39
# 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

#deletePixela::Response

Delete the registered “Pixel”.

Examples:

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

Returns:

Raises:

See Also:



82
83
84
# File 'lib/pixela/pixel.rb', line 82

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

#getPixela::Response

Get registered quantity as “Pixel”.

Examples:

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

Returns:

Raises:

See Also:



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

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

#update(quantity:, optional_data: nil) ⇒ Pixela::Response

Update the quantity already registered as a “Pixel”.

Examples:

client.graph("test-graph").pixel(Date.new(2018, 9, 15)).update(quantity: 7, optional_data: {key: "value"})

Parameters:

  • quantity (Integer, Float)
  • optional_data (Object) (defaults to: nil)

    Additional information other than quantity

Returns:

Raises:

See Also:



68
69
70
# 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