Class: GnipApi::Apis::PowerTrack::Rule

Inherits:
Object
  • Object
show all
Defined in:
lib/gnip_api/apis/power_track/rule.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(params = {}) ⇒ Rule

Returns a new instance of Rule.

[View source]

7
8
9
10
# File 'lib/gnip_api/apis/power_track/rule.rb', line 7

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

Instance Attribute Details

#tagObject

Returns the value of attribute tag.


5
6
7
# File 'lib/gnip_api/apis/power_track/rule.rb', line 5

def tag
  @tag
end

#valueObject

Returns the value of attribute value.


5
6
7
# File 'lib/gnip_api/apis/power_track/rule.rb', line 5

def value
  @value
end

Instance Method Details

#attributesObject

[View source]

16
17
18
19
20
21
# File 'lib/gnip_api/apis/power_track/rule.rb', line 16

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

#to_jsonObject

[View source]

12
13
14
# File 'lib/gnip_api/apis/power_track/rule.rb', line 12

def to_json
  attributes.to_json
end

#uidObject

[View source]

23
24
25
26
27
# File 'lib/gnip_api/apis/power_track/rule.rb', line 23

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