Sha256: 3d140efefbb70226c33f6f322792a588f476fe5ce3c245c45e9b344209de73d5

Contents?: true

Size: 1.27 KB

Versions: 2

Compression:

Stored size: 1.27 KB

Contents

class Java::OrgMitreStixIndicator::IndicatorType
  def item=(val)
    if val.kind_of?(org.mitre.cybox.core.ObservableType)
      self.observable = val
    elsif val.kind_of?(org.mitre.cybox.core.ObjectType)
      self.observable = org.mitre.cybox.core.ObservableType.new(:object => val)
    elsif val.kind_of?(org.mitre.cybox.core.EventType)
      self.observable = org.mitre.cybox.core.ObservableType.new(:event => val)
    elsif val.kind_of?(org.mitre.cybox.common.ObjectPropertiesType)
      self.observable = org.mitre.cybox.core.ObservableType.new(:object => org.mitre.cybox.core.ObjectType.new(:properties => val))
    elsif val.kind_of?(Hash) && val[:operator]
      self.composite_indicator_expression = process_composition(val)
    else
      raise "Unknown item type: #{val.class}"
    end
  end

  def process_composition(composition_hash)
    operator = org.mitre.stix.indicator.OperatorTypeEnum.from_value(composition_hash[:operator].to_s.upcase)
    composition = org.mitre.stix.indicator.CompositeIndicatorExpressionType.new(:operator => operator)
    composition_hash[:items].each do |item|
      indicator = item.kind_of?(org.mitre.stix.common.IndicatorBaseType) ? item : self.class.new(:item => item)
      composition.add_indicator(indicator)
    end

    return composition
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
ruby_stix-0.2.0-java lib/ruby_stix/api/indicator.rb
ruby_stix-0.0.2-java lib/ruby_stix/api/indicator.rb