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.


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

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

Instance Attribute Details

#idObject

Returns the value of attribute id.


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

def id
  @id
end

#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


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

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

#to_jsonObject


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

def to_json
  attributes.to_json
end

#uidObject


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

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