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
-
#add(quantity:) ⇒ Pixela::Response
Add quantity to the “Pixel” of the day.
-
#add_specific(quantity:, date:) ⇒ Pixela::Response
Add quantity to a specific “Pixel”.
-
#create(name:, unit:, type:, color:, timezone: nil, description: nil, start_on_monday: nil, self_sufficient: nil, is_secret: nil, publish_optional_data: nil) ⇒ Pixela::Response
Create a new pixelation graph definition.
-
#decrement ⇒ Pixela::Response
Decrement quantity “Pixel” of the day (UTC).
-
#def ⇒ Pixela::Response
(also: #definition)
Get a predefined pixelation graph definition.
-
#delete ⇒ Pixela::Response
Delete the predefined pixelation graph definition.
-
#increment ⇒ Pixela::Response
Increment quantity “Pixel” of the day (UTC).
-
#initialize(client:, graph_id:) ⇒ Graph
constructor
A new instance of Graph.
-
#latest ⇒ Pixela::Response
This API is used to get latest Pixel of the graph which specified by <graphID> .
- #pixel(date = Date.today) ⇒ Pixela::Pixel
-
#pixel_dates(from: nil, to: nil) ⇒ Array<Date>
Get a Date list of Pixel registered in the graph specified by graphID.
-
#pixels(from: nil, to: nil) ⇒ Array<Hashie::Mash>
Get a Date list of Pixel registered in the graph specified by graphID.
-
#run_stopwatch ⇒ Pixela::Response
(also: #start_stopwatch, #end_stopwatch)
This will start and end the measurement of the time.
-
#stats ⇒ Pixela::Response
Based on the registered information, get various statistics.
-
#subtract(quantity:) ⇒ Pixela::Response
Subtract quantity from the “Pixel” of the day.
-
#subtract_specific(quantity:, date:) ⇒ Pixela::Response
Subtract quantity to a specific “Pixel”.
-
#today(return_empty: false) ⇒ Pixela::Response
This is an endpoint that responds with the Pixel of the day you requested this API.
-
#update(name: nil, unit: nil, color: nil, timezone: nil, description: nil, start_on_monday: nil, purge_cache_urls: nil, self_sufficient: nil, is_secret: nil, publish_optional_data: nil) ⇒ Pixela::Response
Update predefined pixelation graph definitions.
-
#url(date: nil, mode: nil, appearance: nil, less_than: nil, greater_than: 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
#add(quantity:) ⇒ Pixela::Response
Add quantity to the “Pixel” of the day
156 157 158 |
# File 'lib/pixela/graph.rb', line 156 def add(quantity:) client.add_pixel(graph_id: graph_id, quantity: quantity) end |
#add_specific(quantity:, date:) ⇒ Pixela::Response
Add quantity to a specific “Pixel”
300 301 302 |
# File 'lib/pixela/graph.rb', line 300 def add_specific(quantity:, date:) client.add_specific_pixel(graph_id: graph_id, date: date, quantity: quantity) end |
#create(name:, unit:, type:, color:, timezone: nil, description: nil, start_on_monday: nil, self_sufficient: nil, is_secret: nil, publish_optional_data: nil) ⇒ Pixela::Response
Create a new pixelation graph definition.
46 47 48 49 50 51 52 |
# File 'lib/pixela/graph.rb', line 46 def create(name:, unit:, type:, color:, timezone: nil, description: nil, start_on_monday: nil, self_sufficient: nil, is_secret: nil, publish_optional_data: nil) client.create_graph( graph_id: graph_id, name: name, unit: unit, type: type, color: color, timezone: timezone, description: description, start_on_monday: start_on_monday, self_sufficient: self_sufficient, is_secret: is_secret, publish_optional_data: publish_optional_data, ) end |
#decrement ⇒ Pixela::Response
Decrement quantity “Pixel” of the day (UTC).
140 141 142 |
# File 'lib/pixela/graph.rb', line 140 def decrement client.decrement_pixel(graph_id: graph_id) end |
#def ⇒ Pixela::Response Also known as: definition
Get a predefined pixelation graph definition.
251 252 253 |
# File 'lib/pixela/graph.rb', line 251 def def client.get_graph_def(graph_id: graph_id) end |
#delete ⇒ Pixela::Response
Delete the predefined pixelation graph definition.
112 113 114 |
# File 'lib/pixela/graph.rb', line 112 def delete client.delete_graph(graph_id) end |
#increment ⇒ Pixela::Response
Increment quantity “Pixel” of the day (UTC).
126 127 128 |
# File 'lib/pixela/graph.rb', line 126 def increment client.increment_pixel(graph_id: graph_id) end |
#latest ⇒ Pixela::Response
This API is used to get latest Pixel of the graph which specified by <graphID> .
267 268 269 |
# File 'lib/pixela/graph.rb', line 267 def latest client.get_graph_latest(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 |
#pixel_dates(from: nil, to: nil) ⇒ Array<Date>
Get a Date list of Pixel registered in the graph specified by graphID.
189 190 191 |
# File 'lib/pixela/graph.rb', line 189 def pixel_dates(from: nil, to: nil) client.get_pixel_dates(graph_id: graph_id, from: from, to: to) end |
#pixels(from: nil, to: nil) ⇒ Array<Hashie::Mash>
Get a Date list of Pixel registered in the graph specified by graphID.
206 207 208 |
# File 'lib/pixela/graph.rb', line 206 def pixels(from: nil, to: nil) client.get_pixels(graph_id: graph_id, from: from, to: to) end |
#run_stopwatch ⇒ Pixela::Response Also known as: start_stopwatch, end_stopwatch
This will start and end the measurement of the time.
234 235 236 |
# File 'lib/pixela/graph.rb', line 234 def run_stopwatch client.run_stopwatch(graph_id: graph_id) end |
#stats ⇒ Pixela::Response
Based on the registered information, get various statistics.
220 221 222 |
# File 'lib/pixela/graph.rb', line 220 def stats client.get_graph_stats(graph_id: graph_id) end |
#subtract(quantity:) ⇒ Pixela::Response
Subtract quantity from the “Pixel” of the day
172 173 174 |
# File 'lib/pixela/graph.rb', line 172 def subtract(quantity:) client.subtract_pixel(graph_id: graph_id, quantity: quantity) end |
#subtract_specific(quantity:, date:) ⇒ Pixela::Response
Subtract quantity to a specific “Pixel”
317 318 319 |
# File 'lib/pixela/graph.rb', line 317 def subtract_specific(quantity:, date:) client.subtract_specific_pixel(graph_id: graph_id, date: date, quantity: quantity) end |
#today(return_empty: false) ⇒ Pixela::Response
This is an endpoint that responds with the Pixel of the day you requested this API.
283 284 285 |
# File 'lib/pixela/graph.rb', line 283 def today(return_empty: false) client.get_graph_today(graph_id: graph_id, return_empty: return_empty) end |
#update(name: nil, unit: nil, color: nil, timezone: nil, description: nil, start_on_monday: nil, purge_cache_urls: nil, self_sufficient: nil, is_secret: nil, publish_optional_data: nil) ⇒ Pixela::Response
Update predefined pixelation graph definitions.
94 95 96 97 98 99 100 |
# File 'lib/pixela/graph.rb', line 94 def update(name: nil, unit: nil, color: nil, timezone: nil, description: nil, start_on_monday: nil, purge_cache_urls: nil, self_sufficient: nil, is_secret: nil, publish_optional_data: nil) client.update_graph( graph_id: graph_id, name: name, unit: unit, color: color, timezone: timezone, description: description, start_on_monday: start_on_monday, self_sufficient: self_sufficient, purge_cache_urls: purge_cache_urls, is_secret: is_secret, publish_optional_data: publish_optional_data, ) end |
#url(date: nil, mode: nil, appearance: nil, less_than: nil, greater_than: nil) ⇒ String
Get graph url
69 70 71 |
# File 'lib/pixela/graph.rb', line 69 def url(date: nil, mode: nil, appearance: nil, less_than: nil, greater_than: nil) client.graph_url(graph_id: graph_id, date: date, mode: mode, appearance: appearance, less_than: less_than, greater_than: greater_than) end |