Class: Quickeebooks::Shared::Service::Filter

Inherits:
Object
  • Object
show all
Defined in:
lib/quickeebooks/shared/service/filter.rb

Constant Summary collapse

DATE_FORMAT =
'%Y-%m-%d'
DATE_TIME_FORMAT =
'%Y-%m-%dT%H:%M:%S%Z'

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(type, *args) ⇒ Filter

Returns a new instance of Filter.



18
19
20
21
22
23
24
25
# File 'lib/quickeebooks/shared/service/filter.rb', line 18

def initialize(type, *args)
  @type = type
  if args.first.is_a?(Hash)
    args.first.each_pair do |key, value|
      instance_variable_set("@#{key}", value)
    end
  end
end

Instance Attribute Details

#afterObject

For Date/Time filtering



13
14
15
# File 'lib/quickeebooks/shared/service/filter.rb', line 13

def after
  @after
end

#beforeObject

For Date/Time filtering



13
14
15
# File 'lib/quickeebooks/shared/service/filter.rb', line 13

def before
  @before
end

#eqObject

For number comparisons



16
17
18
# File 'lib/quickeebooks/shared/service/filter.rb', line 16

def eq
  @eq
end

#fieldObject

Returns the value of attribute field.



10
11
12
# File 'lib/quickeebooks/shared/service/filter.rb', line 10

def field
  @field
end

#gtObject

For number comparisons



16
17
18
# File 'lib/quickeebooks/shared/service/filter.rb', line 16

def gt
  @gt
end

#ltObject

For number comparisons



16
17
18
# File 'lib/quickeebooks/shared/service/filter.rb', line 16

def lt
  @lt
end

#typeObject (readonly)

Returns the value of attribute type.



9
10
11
# File 'lib/quickeebooks/shared/service/filter.rb', line 9

def type
  @type
end

#valueObject

Returns the value of attribute value.



10
11
12
# File 'lib/quickeebooks/shared/service/filter.rb', line 10

def value
  @value
end

Instance Method Details

#to_sObject



27
28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/quickeebooks/shared/service/filter.rb', line 27

def to_s
  case @type.to_sym
  when :date, :datetime
    date_time_to_s
  when :text
    text_to_s
  when :boolean
    boolean_to_s
  when :number
    number_to_s
  else
    raise ArgumentError, "Don't know how to generate a Filter for type #{@type}"
  end
end

#to_xmlObject



42
43
44
45
46
47
48
49
50
51
# File 'lib/quickeebooks/shared/service/filter.rb', line 42

def to_xml
  case @type.to_sym
  when :text
    text_to_xml
  when :boolean
    boolean_to_xml
  else
    raise ArgumentError, "Don't know how to generate a Filter for type #{@type}"
  end
end