Sha256: aefb1683934b28fd1e2f66c64920ecf733a56eec18fc8e3c308505694efc8990

Contents?: true

Size: 897 Bytes

Versions: 12

Compression:

Stored size: 897 Bytes

Contents

module Qcmd
  module QLab
    class Reply < Struct.new(:osc_message)
      def json
        @json ||= begin
                    Qcmd.debug "[Reply json] parsing osc_message #{ osc_message.to_a.inspect }"
                    JSON.parse(osc_message.to_a.first)
                  rescue => ex
                    Qcmd.debug "[Reply json] json parsing of osc_message failed on message #{ osc_message.to_a.inspect }. #{ ex.message }"
                    {}
                  end
      end

      def address
        @address ||= json['address']
      end

      def data
        @data ||= json['data']
      end

      def has_data?
        !data.nil?
      end

      def status
        @status ||= json['status']
      end

      def empty?
        false
      end

      def to_s
        "<Qcmd::Qlab::Reply address:'#{address}' status:'#{status}' data:#{data.inspect}>"
      end
    end
  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
qcmd-0.2.0 lib/qcmd/qlab/reply.rb
qcmd-0.1.16 lib/qcmd/qlab/reply.rb
qcmd-0.1.16.pre2 lib/qcmd/qlab/reply.rb
qcmd-0.1.16.pre lib/qcmd/qlab/reply.rb
qcmd-0.1.15 lib/qcmd/qlab/reply.rb
qcmd-0.1.14 lib/qcmd/qlab/reply.rb
qcmd-0.1.13 lib/qcmd/qlab/reply.rb
qcmd-0.1.12 lib/qcmd/qlab/reply.rb
qcmd-0.1.11 lib/qcmd/qlab/reply.rb
qcmd-0.1.10 lib/qcmd/qlab/reply.rb
qcmd-0.1.9 lib/qcmd/qlab/reply.rb
qcmd-0.1.8 lib/qcmd/qlab/reply.rb