Sha256: 41bcad8b155a951426cc89708b7585aa1e31bebe6daec42731e278912bcd48d5

Contents?: true

Size: 574 Bytes

Versions: 2

Compression:

Stored size: 574 Bytes

Contents

require 'hashmake'

module SPNet
class Message
  
  include Hashmake::HashMakeable
  
  CONTROL = :messageTypeControl
  COMMAND = :messageTypeCommand
  
  TYPES = [ CONTROL, COMMAND ]
  
  HASHED_ARGS_SPECS = [
    Hashmake::ArgSpec.new(:reqd => true, :key => :type, :type => Symbol, :validator => ->(a){ TYPES.include?(a) } ),
    Hashmake::ArgSpec.new(:reqd => false, :key => :data, :type => Object, :default => nil),
  ]
  
  attr_accessor :data
  attr_reader :type
  
  def initialize hashed_args = {}
    hash_make Message::HASHED_ARGS_SPECS, hashed_args
  end
end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
spnet-0.1.2 lib/spnet/message.rb
spnet-0.1.1 lib/spnet/message.rb