Sha256: 0dadbfbe16f3dbf74c4d55f47fd5a30ae1f8bb8fdfb8bccc24ff16f7636144ac

Contents?: true

Size: 707 Bytes

Versions: 11

Compression:

Stored size: 707 Bytes

Contents

module GnipApi
  module Apis
    module PowerTrack
      class Rule
        attr_accessor :value, :tag, :id

        def initialize params={}
          @value = params[:value] || params['value']
          @tag = params[:tag] || params['tag']
          @id = params[:id] || params['id']
        end

        def to_json
          attributes.to_json
        end

        def attributes
          attrs = {}
          attrs[:value] = @value if @value
          attrs[:tag] = @tag if @tag
          attrs[:id] = @id if @id
          attrs
        end

        def uid
          rule = @value
          rule += "tag:#{@tag}" if @tag
          Digest::SHA2.hexdigest(rule)
        end
      end
    end
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
gnip_api-1.1.3 lib/gnip_api/apis/power_track/rule.rb
gnip_api-1.1.2 lib/gnip_api/apis/power_track/rule.rb
gnip_api-1.1.1 lib/gnip_api/apis/power_track/rule.rb
gnip_api-1.1.0 lib/gnip_api/apis/power_track/rule.rb
gnip_api-1.0.6 lib/gnip_api/apis/power_track/rule.rb
gnip_api-1.0.5 lib/gnip_api/apis/power_track/rule.rb
gnip_api-1.0.4 lib/gnip_api/apis/power_track/rule.rb
gnip_api-1.0.3 lib/gnip_api/apis/power_track/rule.rb
gnip_api-1.0.2 lib/gnip_api/apis/power_track/rule.rb
gnip_api-1.0.1 lib/gnip_api/apis/power_track/rule.rb
gnip_api-1.0.0 lib/gnip_api/apis/power_track/rule.rb