• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

sue445 / pixela / #12148

26 Dec 2025 11:22AM UTC coverage: 44.444% (-53.8%) from 98.195%
#12148

push

web-flow
Merge b4c2c510f into 6f2b98fd6

120 of 270 relevant lines covered (44.44%)

0.44 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

57.89
/lib/pixela/pixel.rb
1
module Pixela
1✔
2
  class Pixel
1✔
3
    # @!attribute [r] client
4
    # @return [Pixela::Client]
5
    attr_reader :client
1✔
6

7
    # @!attribute [r] graph_id
8
    # @return [String]
9
    attr_reader :graph_id
1✔
10

11
    # @!attribute [r] date
12
    # @return [Date]
13
    attr_reader :date
1✔
14

15
    # @param client   [Pixela::Client]
16
    # @param graph_id [String]
17
    # @param date     [Date,Time]
18
    def initialize(client:, graph_id:, date:)
1✔
19
      @client   = client
×
20
      @graph_id = graph_id
×
21
      @date     = date
×
22
    end
23

24
    # It records the quantity of the specified date as a "Pixel".
25
    #
26
    # @param quantity      [Integer,Float]
27
    # @param optional_data [Object] Additional information other than quantity
28
    #
29
    # @return [Pixela::Response]
30
    #
31
    # @raise [Pixela::PixelaError] API is failed
32
    #
33
    # @see https://docs.pixe.la/entry/post-pixel
34
    #
35
    # @example
36
    #   client.graph("test-graph").pixel(Date.new(2018, 9, 15)).create(quantity: 5, optional_data: {key: "value"})
37
    def create(quantity:, optional_data: nil)
1✔
38
      client.create_pixel(graph_id: graph_id, date: date, quantity: quantity, optional_data: optional_data)
×
39
    end
40

41
    # This API is used to register multiple Pixels (quantities for a specific day) at a time.
42
    #
43
    # @param pixels [Array<Hash>] key: date, quantity, optional_data
44
    #
45
    # @return [Pixela::Response]
46
    #
47
    # @raise [Pixela::PixelaError] API is failed
48
    #
49
    # @see https://docs.pixe.la/entry/batch-post-pixels
50
    #
51
    # @example
52
    #   client.graph("test-graph").create_multi(pixels: [{date: Date.new(2018, 9, 15), quantity: 5, optional_data: {key: "value"}}])
53
    def create_multi(pixels:)
1✔
54
      client.create_pixels(graph_id: graph_id, pixels: pixels)
×
55
    end
56

57
    # Get registered quantity as "Pixel".
58
    #
59
    # @return [Pixela::Response]
60
    #
61
    # @raise [Pixela::PixelaError] API is failed
62
    #
63
    # @see https://docs.pixe.la/entry/get-pixel
64
    #
65
    # @example
66
    #   client.graph("test-graph").pixel(Date.new(2018, 9, 15)).get
67
    def get
1✔
68
      client.get_pixel(graph_id: graph_id, date: date)
×
69
    end
70

71
    # Update the quantity already registered as a "Pixel".
72
    #
73
    # @param quantity      [Integer,Float]
74
    # @param optional_data [Object] Additional information other than quantity
75
    #
76
    # @return [Pixela::Response]
77
    #
78
    # @raise [Pixela::PixelaError] API is failed
79
    #
80
    # @see https://docs.pixe.la/entry/put-pixel
81
    #
82
    # @example
83
    #   client.graph("test-graph").pixel(Date.new(2018, 9, 15)).update(quantity: 7, optional_data: {key: "value"})
84
    def update(quantity:, optional_data: nil)
1✔
85
      client.update_pixel(graph_id: graph_id, date: date, quantity: quantity, optional_data: optional_data)
×
86
    end
87

88
    # Delete the registered "Pixel".
89
    #
90
    # @return [Pixela::Response]
91
    #
92
    # @raise [Pixela::PixelaError] API is failed
93
    #
94
    # @see https://docs.pixe.la/entry/delete-pixel
95
    #
96
    # @example
97
    #   client.graph("test-graph").pixel(Date.new(2018, 9, 15)).delete
98
    def delete
1✔
99
      client.delete_pixel(graph_id: graph_id, date: date)
×
100
    end
101
  end
102
end
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc