Class: Pixela::Graph
- Inherits:
-
Object
- Object
- Pixela::Graph
- Defined in:
- lib/pixela/graph.rb
Instance Attribute Summary collapse
- #client ⇒ Pixela::Client readonly
- #graph_id ⇒ String readonly
Instance Method Summary collapse
-
#create(name:, unit:, type:, color:) ⇒ Hashie::Mash
Create a new pixelation graph definition.
-
#decrement ⇒ Hashie::Mash
Decrement quantity "Pixel" of the day (UTC).
-
#increment ⇒ Hashie::Mash
Increment quantity "Pixel" of the day (UTC).
-
#initialize(client:, graph_id:) ⇒ Graph
constructor
A new instance of Graph.
- #pixel(date = Date.today) ⇒ Pixela::Pixel
-
#update(name:, unit:, color:) ⇒ Hashie::Mash
Update predefined pixelation graph definitions.
-
#url(date: nil) ⇒ String
Get graph url.
Constructor Details
#initialize(client:, graph_id:) ⇒ Graph
Returns a new instance of Graph.
13 14 15 16 |
# File 'lib/pixela/graph.rb', line 13 def initialize(client:, graph_id:) @client = client @graph_id = graph_id end |
Instance Attribute Details
#client ⇒ Pixela::Client (readonly)
5 6 7 |
# File 'lib/pixela/graph.rb', line 5 def client @client end |
#graph_id ⇒ String (readonly)
9 10 11 |
# File 'lib/pixela/graph.rb', line 9 def graph_id @graph_id end |
Instance Method Details
#create(name:, unit:, type:, color:) ⇒ Hashie::Mash
Create a new pixelation graph definition.
40 41 42 |
# File 'lib/pixela/graph.rb', line 40 def create(name:, unit:, type:, color:) client.create_graph(graph_id: graph_id, name: name, unit: unit, type: type, color: color) end |
#decrement ⇒ Hashie::Mash
Decrement quantity "Pixel" of the day (UTC).
101 102 103 |
# File 'lib/pixela/graph.rb', line 101 def decrement client.decrement_pixel(graph_id: graph_id) end |
#increment ⇒ Hashie::Mash
Increment quantity "Pixel" of the day (UTC).
87 88 89 |
# File 'lib/pixela/graph.rb', line 87 def increment client.increment_pixel(graph_id: graph_id) end |
#pixel(date = Date.today) ⇒ Pixela::Pixel
21 22 23 |
# File 'lib/pixela/graph.rb', line 21 def pixel(date = Date.today) Pixel.new(client: client, graph_id: graph_id, date: date) end |
#update(name:, unit:, color:) ⇒ Hashie::Mash
Update predefined pixelation graph definitions.
73 74 75 |
# File 'lib/pixela/graph.rb', line 73 def update(name:, unit:, color:) client.update_graph(graph_id: graph_id, name: name, unit: unit, color: color) end |
#url(date: nil) ⇒ String
Get graph url
55 56 57 |
# File 'lib/pixela/graph.rb', line 55 def url(date: nil) client.graph_url(graph_id: graph_id, date: date) end |