Sha256: 83dfe57298a42441bfcac5874c914b29c2d25a40f28ff0542b129d917f6d72a4

Contents?: true

Size: 533 Bytes

Versions: 3

Compression:

Stored size: 533 Bytes

Contents

module Direct::API::V5
  class Response::Units
    def initialize(raw_value)
      @raw_value = raw_value
    end

    def raw
      @raw_value
    end

    # Spent units (by request)
    def spent
      parts[0]
    end

    # Available units (in current hour)
    def available
      parts[1]
    end

    # Units daily limit
    def daily_limit
      parts[2]
    end

    private

    def parts
      @parts ||= @raw_value.to_s.strip.split('/').map do |part|
        part =~ /^\d+$/ ? part.to_i : nil
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
direct-api-v5-0.1.2 lib/direct/api/v5/response/units.rb
direct-api-v5-0.1.1 lib/direct/api/v5/response/units.rb
direct-api-v5-0.1.0 lib/direct/api/v5/response/units.rb