Class: IB::TimeCondition

Inherits:
OrderCondition show all
Defined in:
lib/models/ib/condition.rb

Constant Summary

Constants inherited from OrderCondition

OrderCondition::Subclasses

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from OrderCondition

#default_attributes, make_from, #serialize_contract_by_con_id, verify_contract_if_necessary

Methods included from BaseProperties

#==, #as_table, #content_attributes, #default_attributes, #invariant_attributes, #set_attribute_defaults, #table_header, #table_row, #to_human, #update_missing

Class Method Details

.fabricate(operator, time) ⇒ Object



101
102
103
104
# File 'lib/models/ib/condition.rb', line 101

def self.fabricate operator, time
  self.new operator: operator, 
          time: time
end

.make(buffer) ⇒ Object



78
79
80
81
82
# File 'lib/models/ib/condition.rb', line 78

def self.make  buffer
  self.new  conjunction_connection:  buffer.read_string,
    operator: buffer.read_int,
    time: buffer.read_parse_date
end

Instance Method Details

#condition_typeObject



74
75
76
# File 'lib/models/ib/condition.rb', line 74

def condition_type 
  3
end

#serializeObject



84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
# File 'lib/models/ib/condition.rb', line 84

def serialize
  t =  self[:time]
  if t.is_a?(String) && t =~ /^\d{8}\z/  # expiry-format yyymmmdd
    self.time = DateTime.new t[0..3],t[4..5],t[-2..-1]          
  end
  serialized_time = case self[:time]   # explicity formatting of time-object
                    when String
                      self[:time]
                    when DateTime 
                      self[:time].gmtime.strftime("%Y%m%d %H:%M:%S %Z")
                    when  Date, Time
                      self[:time].strftime("%Y%m%d %H:%M:%S")
                    end

  super << self[:operator] << serialized_time 
end