Class: CF::OutputFormat

Inherits:
Object
  • Object
show all
Includes:
Client
Defined in:
lib/cf/output_format.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ OutputFormat

Specifies output format for a line

Usage Example:

output_format = CF::OutputFormat.new({:station_1 => [{:name => "First Name"}],:station_2 => [{:name => "Mobile", :except => true}]})
line.output_formats output_format


19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/cf/output_format.rb', line 19

def initialize(options={})
  if !options.blank?
    @settings = options
    @line = options[:line] if options[:line].nil? ? nil : options[:line]
    if !@line.nil?
      options.delete(:line)
      request = 
      {
        :body => 
        {
          :api_key => CF.api_key,
          :output_formats => options
        }
      }
      resp = HTTParty.post("#{CF.api_url}#{CF.api_version}/lines/#{CF.}/#{@line.title.downcase}/output_format.json",request)
      self.errors = resp.parsed_response['error']['message'] if resp.code != 200
      self.line.output_formats = self
    end
  end
end

Instance Attribute Details

#errorsObject

Contains error message if any



10
11
12
# File 'lib/cf/output_format.rb', line 10

def errors
  @errors
end

#lineObject

Line object for which output_format is specified



13
14
15
# File 'lib/cf/output_format.rb', line 13

def line
  @line
end

#settingsObject

output_format settings



7
8
9
# File 'lib/cf/output_format.rb', line 7

def settings
  @settings
end