Class: Gnip::Rule

Inherits:
Object
  • Object
show all
Defined in:
lib/gnip-rules/rule.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(v, t = nil) ⇒ Rule

Returns a new instance of Rule.



6
7
8
9
10
# File 'lib/gnip-rules/rule.rb', line 6

def initialize( v , t = nil )
  @value = v
  @tag = t
  @errors = []
end

Instance Attribute Details

#errorsObject

Returns the value of attribute errors.



4
5
6
# File 'lib/gnip-rules/rule.rb', line 4

def errors
  @errors
end

#tagObject

Returns the value of attribute tag.



4
5
6
# File 'lib/gnip-rules/rule.rb', line 4

def tag
  @tag
end

#valueObject

Returns the value of attribute value.



4
5
6
# File 'lib/gnip-rules/rule.rb', line 4

def value
  @value
end

Instance Method Details

#as_json(options = {}) ⇒ Object



12
13
14
15
16
# File 'lib/gnip-rules/rule.rb', line 12

def as_json(options={})
  o = {"value" => value}
  o.merge!( "tag" => tag ) unless tag.nil?
  return o
end

#valid?Boolean

Returns:

  • (Boolean)


18
19
20
# File 'lib/gnip-rules/rule.rb', line 18

def valid?
  validate_length
end