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).
-
#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.
- #notification(notification_id) ⇒ Pixela::Notification
- #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.
-
#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.
51 52 53 54 55 56 |
# File 'lib/pixela/graph.rb', line 51 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).
138 139 140 |
# File 'lib/pixela/graph.rb', line 138 def decrement client.decrement_pixel(graph_id: graph_id) end |
#delete ⇒ Pixela::Response
Delete the predefined pixelation graph definition.
110 111 112 |
# File 'lib/pixela/graph.rb', line 110 def delete client.delete_graph(graph_id) end |
#increment ⇒ Pixela::Response
Increment quantity "Pixel" of the day (UTC).
124 125 126 |
# File 'lib/pixela/graph.rb', line 124 def increment client.increment_pixel(graph_id: graph_id) end |
#notification(notification_id) ⇒ Pixela::Notification
28 29 30 |
# File 'lib/pixela/graph.rb', line 28 def notification(notification_id) Notification.new(client: client, graph_id: graph_id, notification_id: notification_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.
155 156 157 |
# File 'lib/pixela/graph.rb', line 155 def pixel_dates(from: nil, to: nil) client.get_pixel_dates(graph_id: graph_id, from: from, to: to) end |
#stats ⇒ Pixela::Response
Based on the registered information, get various statistics.
169 170 171 |
# File 'lib/pixela/graph.rb', line 169 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.
93 94 95 96 97 98 |
# File 'lib/pixela/graph.rb', line 93 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
70 71 72 |
# File 'lib/pixela/graph.rb', line 70 def url(date: nil, mode: nil) client.graph_url(graph_id: graph_id, date: date, mode: mode) end |