Sha256: 99de7097bd360954da0ed4e6312c9d78375aab9753b5d1c4a5c67e1980ef3571

Contents?: true

Size: 669 Bytes

Versions: 5

Compression:

Stored size: 669 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

5 entries across 5 versions & 1 rubygems

Version Path
npr-3.0.0 lib/npr/api/message.rb
npr-2.0.2 lib/npr/api/message.rb
npr-2.0.1 lib/npr/api/message.rb
npr-2.0.0 lib/npr/api/message.rb
npr-1.2.0 lib/npr/api/message.rb