Class: Pixela::Graph

Inherits:
Object
  • Object
show all
Defined in:
lib/pixela/graph.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(client:, graph_id:) ⇒ Graph

Returns a new instance of Graph

Parameters:


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

#clientPixela::Client (readonly)

Returns:


5
6
7
# File 'lib/pixela/graph.rb', line 5

def client
  @client
end

#graph_idString (readonly)

Returns:

  • (String)

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.

Examples:

client.graph("test-graph").create(name: "graph-name", unit: "commit", type: "int", color: "shibafu", timezone: "Asia/Tokyo", self_sufficient: "increment", is_secret: true, publish_optional_data: true)

Parameters:

  • name (String)
  • unit (String)
  • type (String)
  • color (String)
  • timezone (String)
  • self_sufficient (String)

    If SVG graph with this field increment or decrement is referenced, Pixel of this graph itself will be incremented or decremented

  • is_secret (Boolean)
  • publish_optional_data (Boolean)

Returns:

Raises:

See Also:


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

#decrementPixela::Response

Decrement quantity "Pixel" of the day (UTC).

Examples:

client.graph("test-graph").decrement

Returns:

Raises:

See Also:


138
139
140
# File 'lib/pixela/graph.rb', line 138

def decrement
  client.decrement_pixel(graph_id: graph_id)
end

#deletePixela::Response

Delete the predefined pixelation graph definition.

Examples:

client.graph("test-graph").delete

Returns:

Raises:

See Also:


110
111
112
# File 'lib/pixela/graph.rb', line 110

def delete
  client.delete_graph(graph_id)
end

#incrementPixela::Response

Increment quantity "Pixel" of the day (UTC).

Examples:

client.graph("test-graph").increment

Returns:

Raises:

See Also:


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

Parameters:

  • notification_id (String)

Returns:


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

Parameters:

  • date (Date, Time) (defaults to: Date.today)

Returns:


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.

Examples:

client.graph("test-graph").pixel_dates(from: Date.new(2018, 1, 1), to: Date.new(2018, 12, 31))

Parameters:

  • from (Date)

    Specify the start position of the period.

  • to (Date)

    Specify the end position of the period.

Returns:

  • (Array<Date>)

Raises:

See Also:


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

#statsPixela::Response

Based on the registered information, get various statistics.

Examples:

client.graph("test-graph").stats

Returns:

Raises:

See Also:


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.

Examples:

client.graph("test-graph").update(name: "graph-name", unit: "commit", color: "shibafu", timezone: "Asia/Tokyo", purge_cache_urls: ["https://camo.githubusercontent.com/xxx/xxxx"])

Parameters:

  • name (String)
  • unit (String)
  • color (String)
  • timezone (String)
  • self_sufficient (String)

    If SVG graph with this field increment or decrement is referenced, Pixel of this graph itself will be incremented or decremented

  • purge_cache_urls (String, Array<String>)
  • is_secret (Boolean)
  • publish_optional_data (Boolean)

Returns:

Raises:

See Also:


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

Examples:

client.graph("test-graph").url
client.graph("test-graph").url(date: Date.new(2018, 3, 31), mode: "short")

Parameters:

  • date (Date, Time)
  • mode (String)

    e.g) short

Returns:

  • (String)

See Also:


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