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.
-
#create(name:, unit:, type:, color:, timezone: 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
. - #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.
-
#update(name: nil, unit: nil, color: nil, timezone: 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
150 151 152 |
# File 'lib/pixela/graph.rb', line 150 def add(quantity:) client.add_pixel(graph_id: graph_id, quantity: quantity) end |
#create(name:, unit:, type:, color:, timezone: nil, self_sufficient: nil, is_secret: nil, publish_optional_data: nil) ⇒ Pixela::Response
Create a new pixelation graph definition.
44 45 46 47 48 49 |
# File 'lib/pixela/graph.rb', line 44 def create(name:, unit:, type:, color:, timezone: 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, 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).
134 135 136 |
# File 'lib/pixela/graph.rb', line 134 def decrement client.decrement_pixel(graph_id: graph_id) end |
#def ⇒ Pixela::Response Also known as: definition
Get a predefined pixelation graph definition.
245 246 247 |
# File 'lib/pixela/graph.rb', line 245 def def client.get_graph_def(graph_id: graph_id) end |
#delete ⇒ Pixela::Response
Delete the predefined pixelation graph definition.
106 107 108 |
# File 'lib/pixela/graph.rb', line 106 def delete client.delete_graph(graph_id) end |
#increment ⇒ Pixela::Response
Increment quantity "Pixel" of the day (UTC).
120 121 122 |
# File 'lib/pixela/graph.rb', line 120 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
261 262 263 |
# File 'lib/pixela/graph.rb', line 261 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.
183 184 185 |
# File 'lib/pixela/graph.rb', line 183 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.
200 201 202 |
# File 'lib/pixela/graph.rb', line 200 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.
228 229 230 |
# File 'lib/pixela/graph.rb', line 228 def run_stopwatch client.run_stopwatch(graph_id: graph_id) end |
#stats ⇒ Pixela::Response
Based on the registered information, get various statistics.
214 215 216 |
# File 'lib/pixela/graph.rb', line 214 def stats client.get_graph_stats(graph_id: graph_id) end |
#subtract(quantity:) ⇒ Pixela::Response
Subtract quantity from the "Pixel" of the day
166 167 168 |
# File 'lib/pixela/graph.rb', line 166 def subtract(quantity:) client.subtract_pixel(graph_id: graph_id, quantity: quantity) end |
#update(name: nil, unit: nil, color: nil, timezone: nil, purge_cache_urls: nil, self_sufficient: nil, is_secret: nil, publish_optional_data: nil) ⇒ Pixela::Response
Update predefined pixelation graph definitions.
89 90 91 92 93 94 |
# File 'lib/pixela/graph.rb', line 89 def update(name: nil, unit: nil, color: nil, timezone: 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, 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
66 67 68 |
# File 'lib/pixela/graph.rb', line 66 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 |