Class: CF::CustomTaskForm
- Inherits:
-
Object
- Object
- CF::CustomTaskForm
- Includes:
- Client
- Defined in:
- lib/cf/custom_task_form.rb
Instance Attribute Summary (collapse)
-
- (Object) instruction
Description of "custom_instruction" object, e.g.
-
- (Object) raw_css
raw_css is an attribute to store the custom css contents.
-
- (Object) raw_html
raw_html is an attribute to store the custom html contents.
-
- (Object) raw_javascript
raw_javascript is an attribute to store the custom javascript contents.
-
- (Object) station
station attribute is required for association with custom_from object.
-
- (Object) title
Title of "custom_instruction" object, e.g.
Class Method Summary (collapse)
-
+ (Object) create(form)
Initializes a new CustomForm within block using Variable
Usage of custom_instruction.create(instruction):
Creating CustomForm using block variable.
Instance Method Summary (collapse)
-
- (Object) css(css_content = nil)
Usage of instruction.css:.
-
- (Object) css=(css_content)
:nodoc:.
-
- (Object) html(html_content = nil)
Usage of instruction.html:.
-
- (Object) html=(html_content)
:nodoc:.
-
- (CustomTaskForm) initialize(options = {})
constructor
Initializes a new CustomForm
Usage custom_instruction.new(hash):.
-
- (Object) javascript(javascript_content = nil)
Usage of instruction.javascript:.
-
- (Object) javascript=(javascript_content)
:nodoc:.
Constructor Details
- (CustomTaskForm) initialize(options = {})
Initializes a new CustomForm
Usage custom_instruction.new(hash):
attrs = {:title => "Enter text from a business card image",
:description => "Describe"}
instruction = CustomForm.new(attrs)
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/cf/custom_task_form.rb', line 30 def initialize(={}) @station = [:station] @title = [:title] @instruction = [:instruction] @raw_html = [:raw_html] @raw_css = [:raw_css] @raw_javascript = [:raw_javascript] if @station @resp = self.class.post("/lines/#{CF.account_name}/#{@station.line_title.downcase}/stations/#{@station.index}/form.json", :form => {:title => @title, :instruction => @instruction, :_type => "CustomTaskForm", :raw_html => @raw_html, :raw_css => @raw_css, :raw_javascript => @raw_javascript}) # custom task form response not well formatted # @id = @resp.from.id custom_form = CF::CustomTaskForm.new({}) @resp.to_hash.each_pair do |k,v| custom_form.send("#{k}=",v) if custom_form.respond_to?(k) end custom_form.station = @station @station.form = custom_form end end |
Instance Attribute Details
- (Object) instruction
Description of "custom_instruction" object, e.g. :description => "description for title of custom_instruction"
9 10 11 |
# File 'lib/cf/custom_task_form.rb', line 9 def instruction @instruction end |
- (Object) raw_css
raw_css is an attribute to store the custom css contents
15 16 17 |
# File 'lib/cf/custom_task_form.rb', line 15 def raw_css @raw_css end |
- (Object) raw_html
raw_html is an attribute to store the custom html contents
12 13 14 |
# File 'lib/cf/custom_task_form.rb', line 12 def raw_html @raw_html end |
- (Object) raw_javascript
raw_javascript is an attribute to store the custom javascript contents
18 19 20 |
# File 'lib/cf/custom_task_form.rb', line 18 def raw_javascript @raw_javascript end |
- (Object) station
station attribute is required for association with custom_from object
21 22 23 |
# File 'lib/cf/custom_task_form.rb', line 21 def station @station end |
- (Object) title
Title of "custom_instruction" object, e.g. :title => "title_name of custom_instruction"
6 7 8 |
# File 'lib/cf/custom_task_form.rb', line 6 def title @title end |
Class Method Details
+ (Object) create(form)
Initializes a new CustomForm within block using Variable
Usage of custom_instruction.create(instruction):
Creating CustomForm using block variable
attrs = {:title => "Enter text from a business card image",
:description => "Describe"}
html_content = '<div>.........</div>'
css_content = 'body {background:#fbfbfb;}
#instructions{
text-align:center;
}.....'
javascript_content = '<script>.........</script>'
instruction = CustomForm.create(instruction) do |i|
i.html = html_content
i.css = css_content
i.javascript = javascript_content
end
OR without block variable
instruction = CustomForm.create(instruction) do
html html_content
css css_content
javascript javascript_content
end
78 79 80 81 82 83 84 85 86 |
# File 'lib/cf/custom_task_form.rb', line 78 def self.create(form) instruction = CustomTaskForm.new(form) # if block.arity >= 1 # block.call(instruction) # else # instruction.instance_eval &block # end # instruction end |
Instance Method Details
- (Object) css(css_content = nil)
Usage of instruction.css:
css_content = 'body {background:#fbfbfb;}
#instructions{
text-align:center;
}.....'
instruction.css = css_content
111 112 113 114 115 116 117 |
# File 'lib/cf/custom_task_form.rb', line 111 def css css_content = nil if css_content @css_content = css_content else @css_content end end |
- (Object) css=(css_content)
:nodoc:
118 119 120 |
# File 'lib/cf/custom_task_form.rb', line 118 def css=(css_content) # :nodoc: @css_content = css_content end |
- (Object) html(html_content = nil)
Usage of instruction.html:
html_content = '<div>.........</div>'
instruction.html = html_content
93 94 95 96 97 98 99 |
# File 'lib/cf/custom_task_form.rb', line 93 def html html_content = nil if html_content @html_content = html_content else @html_content end end |
- (Object) html=(html_content)
:nodoc:
100 101 102 |
# File 'lib/cf/custom_task_form.rb', line 100 def html=(html_content) # :nodoc: @html_content = html_content end |
- (Object) javascript(javascript_content = nil)
Usage of instruction.javascript:
javascript_content = '<script>.........</script>'
instruction.html = javascript_content
125 126 127 128 129 130 131 |
# File 'lib/cf/custom_task_form.rb', line 125 def javascript javascript_content = nil if javascript_content @javascript_content = javascript_content else @javascript_content end end |
- (Object) javascript=(javascript_content)
:nodoc:
132 133 134 |
# File 'lib/cf/custom_task_form.rb', line 132 def javascript=(javascript_content) # :nodoc: @javascript_content = javascript_content end |