Sha256: e8daf55f6ad59b334525bcc0d67b477e6c5864d53cd5d80c34c774367261a531

Contents?: true

Size: 693 Bytes

Versions: 4

Compression:

Stored size: 693 Bytes

Contents

##
# NPR::API::Message
#
# If the API returns any messages, use this class
# to represent it.
#
module NPR
  module API
    class Message
      include NPR::Concern::ShallowAttributes
      
      attr_accessor :id, :level
      shallow_attribute "text", "timestamp"

      #------------------
    
      def initialize(json)
        @_json = json
        @id    = @_json["id"]
        @level = @_json["level"]
      
        extract_shallow_attributes(@_json)
      end

      #------------------
    
      def error?
        self.level == "error"
      end
    
      #------------------

      def warning?
        self.level == "warning"
      end
    end # Message
  end # API
end # NPR

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
npr-1.1.0 lib/npr/api/message.rb
npr-0.1.2 lib/npr/api/message.rb
npr-0.1.1 lib/npr/api/message.rb
npr-0.1.0 lib/npr/api/message.rb