Class: CF::InputFormat
- Inherits:
-
Object
- Object
- CF::InputFormat
- Includes:
- Client
- Defined in:
- lib/cf/input_format.rb
Instance Attribute Summary (collapse)
-
- (Object) errors
ID of Line with which input_format is associated.
-
- (Object) id
ID of an input_format.
-
- (Object) line_title
ID of Line with which input_format is associated.
-
- (Object) name
name for the input_format, e.g.
-
- (Object) required
required boolean either true or false , e.g.
-
- (Object) valid_type
valid_type format of the source for the input_format, e.g.
Class Method Summary (collapse)
-
+ (Object) all(line)
Returns all the input headers of a specific line.
Instance Method Summary (collapse)
-
- (Object) delete
line = CF::Line.new("Digitize Card","Survey").
-
- (Object) get
Returns a particular input header of a specific line
Usage example.
-
- (InputFormat) initialize(options = {})
constructor
Initializes a new input_format
-
Syntax for creating new input_format: InputFormat.new( Hash )
Usage Example:.
-
-
- (Object) update(options = {})
Updates input header
Usage example.
Constructor Details
- (InputFormat) initialize(options = {})
Initializes a new input_format
-
Syntax for creating new input_format: InputFormat.new( Hash )
Usage Example:
line = CF::Line.create("Digitize", "Survey")
attrs = {:line => line,
:name => "image_url",
:required => true,
:valid_type => "url"}
input_format = CF::InputFormat.new(attrs)
line.input_formats input_format
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/cf/input_format.rb', line 32 def initialize(={}) @station = [:station] @line = [:line] @name = [:name] @required = [:required] @valid_type = [:valid_type] if !@station.nil? or !@line.nil? line_title = @station.nil? ? @line.title : @station.line_title resp = self.class.post("/lines/#{CF.account_name}/#{@line.title.downcase}/input_formats.json", :input_format => {:name => @name, :required => @required, :valid_type => @valid_type}) if resp.code != 200 self.errors = resp.error. end @line_title = line_title if !@station.nil? && @station.except.nil? && @station.extra.nil? @station.input_formats = self else @line.input_formats = self end end end |
Instance Attribute Details
- (Object) errors
ID of Line with which input_format is associated
18 19 20 |
# File 'lib/cf/input_format.rb', line 18 def errors @errors end |
- (Object) id
ID of an input_format
15 16 17 |
# File 'lib/cf/input_format.rb', line 15 def id @id end |
- (Object) line_title
ID of Line with which input_format is associated
18 19 20 |
# File 'lib/cf/input_format.rb', line 18 def line_title @line_title end |
- (Object) name
name for the input_format, e.g. :name => "image_url"
6 7 8 |
# File 'lib/cf/input_format.rb', line 6 def name @name end |
- (Object) required
required boolean either true or false , e.g. :required => "true" & if false then you don't need to mention
9 10 11 |
# File 'lib/cf/input_format.rb', line 9 def required @required end |
- (Object) valid_type
valid_type format of the source for the input_format, e.g. :valid_type => "url"
12 13 14 |
# File 'lib/cf/input_format.rb', line 12 def valid_type @valid_type end |
Class Method Details
+ (Object) all(line)
Returns all the input headers of a specific line
line = CF::Line.new("Digitize Card","Survey")
attrs_1 = {:line => line,
:name => "image_url",
:required => true,
:valid_type => "url"
}
attrs_2 = {:line => line,
:name => "text_url",
:required => true,
:valid_type => "url"
}
input_format_1 = CF::InputFormat.new(attrs_1)
line.input_formats input_format_1
input_format_2 = CF::InputFormat.new(attrs_2)
line.input_formats input_format_2
input_formats_of_line = CF::InputFormat.all(line)
returns an array of input headers associated with line
74 75 76 |
# File 'lib/cf/input_format.rb', line 74 def self.all(line) get("/lines/#{CF.account_name}/#{line.title.downcase}/input_formats.json") end |
Instance Method Details
- (Object) delete
line = CF::Line.new("Digitize Card","Survey")
attrs = {:line => line,
:name => "image_url_type",
:required => true,
:valid_type => "url"
}
input_format = CF::InputFormat.new(attrs)
line.input_formats input_format
input_format = line.input_formats[0]
input_format.delete
deletes input header
130 131 132 |
# File 'lib/cf/input_format.rb', line 130 def delete self.class.delete("/lines/#{line_id}/input_formats/#{id}.json") end |
- (Object) get
Returns a particular input header of a specific line
Usage example
line = CF::Line.new("Digitize Card","Survey")
attrs = {:line => line,
:name => "image_url_type",
:required => true,
:valid_type => "url"
}
input_format = CF::InputFormat.new(attrs)
line.input_formats input_format
input_format = line.input_formats[0]
got_input_format = input_format.get
92 93 94 |
# File 'lib/cf/input_format.rb', line 92 def get self.class.get("/lines/#{line_id}/input_formats/#{id}.json") end |
- (Object) update(options = {})
Updates input header
Usage example
line = CF::Line.new("Digitize Card","Survey")
attrs = {:line => line,
:name => "image_url_type",
:required => true,
:valid_type => "url"
}
input_format = CF::InputFormat.new(attrs)
line.input_formats input_format
input_format = line.input_formats[0]
updated_input_format = input_format.update({:name => "jackpot", :field_type => "lottery"})
110 111 112 113 114 115 |
# File 'lib/cf/input_format.rb', line 110 def update(={}) @name = [:name] @required = [:required] @valid_type = [:valid_type] self.class.put("/lines/#{line_id}/input_formats/#{id}.json", :input_format => {:name => @name, :required => @required, :valid_type => @valid_type}) end |