Class: DYI::Script::SimpleScript
- Inherits:
-
Object
- Object
- DYI::Script::SimpleScript
- Defined in:
- lib/dyi/script/simple_script.rb
Overview
Class representing a inline-client-script. The scripting becomes effective only when it is output by SVG format.
Direct Known Subclasses
Instance Attribute Summary collapse
-
#body ⇒ String
readonly
Body of client scripting.
-
#content_type ⇒ String
readonly
Content-type of script.
Instance Method Summary collapse
-
#append_body(script_body) ⇒ Object
Appends script.
- #contents ⇒ Object
-
#has_uri_reference? ⇒ Boolean
Returns this script includes reference of external script file.
-
#include_external_file? ⇒ Boolean
Returns this script includes reference of external script file.
-
#initialize(body, content_type = 'application/ecmascript') ⇒ SimpleScript
constructor
A new instance of SimpleScript.
-
#write_as(formatter, io = $>) ⇒ Object
Writes the buffer contents of the object.
Constructor Details
#initialize(body, content_type = 'application/ecmascript') ⇒ SimpleScript
Returns a new instance of SimpleScript.
39 40 41 42 |
# File 'lib/dyi/script/simple_script.rb', line 39 def initialize(body, content_type = 'application/ecmascript') @content_type = content_type @body = body end |
Instance Attribute Details
#body ⇒ String (readonly)
Returns body of client scripting.
35 36 37 |
# File 'lib/dyi/script/simple_script.rb', line 35 def body @body end |
#content_type ⇒ String (readonly)
Returns content-type of script.
33 34 35 |
# File 'lib/dyi/script/simple_script.rb', line 33 def content_type @content_type end |
Instance Method Details
#append_body(script_body) ⇒ Object
Appends script.
59 60 61 62 63 64 65 |
# File 'lib/dyi/script/simple_script.rb', line 59 def append_body(script_body) if @body.to_s[-1,1] == "\n" @body += script_body else @body = [@body, "\n", script_body].join end end |
#contents ⇒ Object
68 69 70 |
# File 'lib/dyi/script/simple_script.rb', line 68 def contents @body end |
#has_uri_reference? ⇒ Boolean
Returns this script includes reference of external script file.
52 53 54 |
# File 'lib/dyi/script/simple_script.rb', line 52 def has_uri_reference? false end |
#include_external_file? ⇒ Boolean
Returns this script includes reference of external script file.
46 47 48 |
# File 'lib/dyi/script/simple_script.rb', line 46 def include_external_file? false end |
#write_as(formatter, io = $>) ⇒ Object
Writes the buffer contents of the object.
75 76 77 |
# File 'lib/dyi/script/simple_script.rb', line 75 def write_as(formatter, io=$>) formatter.write_script(self, io) end |