Class: Es::DurationField

Inherits:
Field
  • Object
show all
Defined in:
lib/es.rb

Constant Summary

Constants inherited from Field

Field::ATTRIBUTE_TYPE, Field::AUTOINCREMENT_TYPE, Field::DATE_TYPE, Field::DURATION_TYPE, Field::FACT_TYPE, Field::FIELD_TYPES, Field::HID_TYPE, Field::HISTORIC_TYPE, Field::IS_DELETED_TYPE, Field::RECORDID_TYPE, Field::SNAPSHOT_TYPE, Field::TIMEATTRIBUTE_TYPE, Field::TIMESTAMP_TYPE, Field::TIME_TYPE, Field::VELOCITY_TYPE

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Field

#==, #is_attribute?, #is_autoincrement?, #is_date?, #is_fact?, #is_hid?, #is_recordid?, #is_snapshot?, #is_timestamp?, #is_velocity?, parse, #to_config_generator, #to_config_generator_extract, #to_load_config, #to_load_fragment

Constructor Details

#initialize(name, type, options = {}) ⇒ DurationField

Returns a new instance of DurationField.



818
819
820
821
822
823
# File 'lib/es.rb', line 818

def initialize(name, type, options = {})
  super(name, type)
  @attribute = options[:attribute] || "IsClosed"
  @value =  options[:value]        || "false"
  @control_attribute = options[:control_attribute] || "StageName"
end

Instance Attribute Details

#attributeObject

Returns the value of attribute attribute.



816
817
818
# File 'lib/es.rb', line 816

def attribute
  @attribute
end

#control_attributeObject

Returns the value of attribute control_attribute.



816
817
818
# File 'lib/es.rb', line 816

def control_attribute
  @control_attribute
end

#nameObject

Returns the value of attribute name.



816
817
818
# File 'lib/es.rb', line 816

def name
  @name
end

#typeObject

Returns the value of attribute type.



816
817
818
# File 'lib/es.rb', line 816

def type
  @type
end

#valueObject

Returns the value of attribute value.



816
817
818
# File 'lib/es.rb', line 816

def value
  @value
end

Instance Method Details

#is_duration?Boolean

Returns:

  • (Boolean)


825
826
827
# File 'lib/es.rb', line 825

def is_duration?
  true
end

#to_extract_fragment(pid, fields, options = {}) ⇒ Object



829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
# File 'lib/es.rb', line 829

def to_extract_fragment(pid, fields, options = {})
  {
      :name       => "StageDuration",
      :preferred  => "stageduration",
      :definition => {
          :type => "case",
          :ops  => [{
              :type => "option",
              :ops => [{
                  :type => "=",
                  :ops => [{
                      :type => "stream",
                      :data => attribute
                  },
                  {
                      :type => "match",
                      :data => value
                  }]
              },
              {
                  :type => "duration",
                  :ops  => [{
                      :type => "stream",
                      :data => control_attribute
                  }]
              }]
          },
          {
              :type => "option",
              :ops  => [{
                  :type => "const",
                  :data => 1
              },
              {
                  :type => "const",
                  :data => 0
              }]
          }]
      }
  }
end