class Hive::Operation

Constants

IDS

IDs derrived from: gitlab.syncad.com/hive/hive/-/blob/master/libraries/protocol/include/hive/protocol/operations.hpp

Public Class Methods

op_id(op) click to toggle source
# File lib/hive/operation.rb, line 107
def self.op_id(op)
  IDS.find_index op
end

Public Instance Methods

==(other_op) click to toggle source
# File lib/hive/operation.rb, line 144
def ==(other_op)
  return false if self.class != other_op.class
  
  self.class.attributes.each do |prop|
    return false if self[prop] != other_op[prop]
  end
  
  true
end
[](key) click to toggle source
# File lib/hive/operation.rb, line 127
def [](key)
  key = key.to_sym
  send(key) if self.class.attributes.include?(key)
end
[]=(key, value) click to toggle source
# File lib/hive/operation.rb, line 132
def []=(key, value)
  key = key.to_sym
  
  if self.class.attributes.include?(key)
    if self.class.numeric? key
      send("#{key}=", value.to_i)
    else
      send("#{key}=", value)
    end
  end
end
inspect() click to toggle source
# File lib/hive/operation.rb, line 111
def inspect
  properties = self.class.attributes.map do |prop|
    unless (v = instance_variable_get("@#{prop}")).nil?
      v = if v.respond_to? :strftime
        v.strftime('%Y-%m-%dT%H:%M:%S')
      else
        v
      end
      
      "@#{prop}=#{v}"
    end
  end.compact.join(', ')
  
  "#<#{self.class.name} [#{properties}]>"
end