Sha256: 1f81582f7c8112f71e956fade495a0ce32125840f288a336dacc8447a299b2f7

Contents?: true

Size: 462 Bytes

Versions: 4

Compression:

Stored size: 462 Bytes

Contents

require 'json'
require 'librato/chart'

module Librato
  class Space < Struct.new(:client, :data, :config)
    def id
      data['id'] || fail("Unknown id: #{data}")
    end

    def name
      data['name']
    end

    def charts
      @charts ||= fetch.map { |data| Chart.new(client, self, data) }
    end

    def path
      "/v1/spaces/#{data['id']}/charts"
    end

    private

      def fetch
        JSON.parse(client.get(path).body)
      end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
librato-0.0.7 lib/librato/space.rb
librato-0.0.6 lib/librato/space.rb
librato-0.0.5 lib/librato/space.rb
librato-0.0.4 lib/librato/space.rb