Sha256: 0c388345480286acada930093410aecb7c8b68478ca16adf7dd3614527df54c0

Contents?: true

Size: 448 Bytes

Versions: 2

Compression:

Stored size: 448 Bytes

Contents

require "ostruct"
require "delegate"

module PodcastIndex
  class Stats < SimpleDelegator
    class << self
      def current
        response = Api::Stats.current
        from_response(response)
      end

    private

      def from_response(response)
        value = response["stats"].transform_keys(&:underscore)
        new(JSON.parse(value.to_json, object_class: OpenStruct)) # rubocop:disable Style/OpenStructUse
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
podcast_index-0.5.0 lib/podcast_index/stats.rb
podcast_index-0.4.0 lib/podcast_index/stats.rb