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:, 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.
- #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.
-
#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) ⇒ 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:, 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).
131 132 133 |
# File 'lib/pixela/graph.rb', line 131 def decrement client.decrement_pixel(graph_id: graph_id) end |
#def ⇒ Pixela::Response Also known as: definition
Get a predefined pixelation graph definition.
210 211 212 |
# File 'lib/pixela/graph.rb', line 210 def def client.get_graph_def(graph_id: graph_id) end |
#delete ⇒ Pixela::Response
Delete the predefined pixelation graph definition.
103 104 105 |
# File 'lib/pixela/graph.rb', line 103 def delete client.delete_graph(graph_id) end |
#increment ⇒ Pixela::Response
Increment quantity "Pixel" of the day (UTC).
117 118 119 |
# File 'lib/pixela/graph.rb', line 117 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 |
#pixel_dates(from: nil, to: nil) ⇒ Array<Date>
Get a Date list of Pixel registered in the graph specified by graphID.
148 149 150 |
# File 'lib/pixela/graph.rb', line 148 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.
165 166 167 |
# File 'lib/pixela/graph.rb', line 165 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.
193 194 195 |
# File 'lib/pixela/graph.rb', line 193 def run_stopwatch client.run_stopwatch(graph_id: graph_id) end |
#stats ⇒ Pixela::Response
Based on the registered information, get various statistics.
179 180 181 |
# File 'lib/pixela/graph.rb', line 179 def stats client.get_graph_stats(graph_id: graph_id) 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.
86 87 88 89 90 91 |
# File 'lib/pixela/graph.rb', line 86 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) ⇒ String
Get graph url
63 64 65 |
# File 'lib/pixela/graph.rb', line 63 def url(date: nil, mode: nil) client.graph_url(graph_id: graph_id, date: date, mode: mode) end |