Class: CodeInclusion::Code
- Inherits:
-
Object
- Object
- CodeInclusion::Code
- Defined in:
- lib/polytexnic/code_inclusion.rb
Constant Summary collapse
- DEFAULT_LANGUAGE =
'text'
Instance Attribute Summary collapse
-
#render_args ⇒ Object
readonly
Returns the value of attribute render_args.
-
#retrieval_args ⇒ Object
readonly
Returns the value of attribute retrieval_args.
Class Method Summary collapse
-
.for(line) ⇒ Object
Returns an instance of CodeInclusion::Code or nil.
Instance Method Summary collapse
-
#initialize(retrieval_args, render_args) ⇒ Code
constructor
A new instance of Code.
-
#to_s ⇒ Object
Returns the formatted code or an error message.
Constructor Details
#initialize(retrieval_args, render_args) ⇒ Code
Returns a new instance of Code.
156 157 158 |
# File 'lib/polytexnic/code_inclusion.rb', line 156 def initialize(retrieval_args, render_args) @retrieval_args, @render_args = retrieval_args, render_args end |
Instance Attribute Details
#render_args ⇒ Object (readonly)
Returns the value of attribute render_args.
154 155 156 |
# File 'lib/polytexnic/code_inclusion.rb', line 154 def render_args @render_args end |
#retrieval_args ⇒ Object (readonly)
Returns the value of attribute retrieval_args.
154 155 156 |
# File 'lib/polytexnic/code_inclusion.rb', line 154 def retrieval_args @retrieval_args end |
Class Method Details
Instance Method Details
#to_s ⇒ Object
Returns the formatted code or an error message
161 162 163 164 165 166 167 168 169 170 171 172 |
# File 'lib/polytexnic/code_inclusion.rb', line 161 def to_s return unless filename result = [] result << "%= lang:#{language}#{highlight}" result << '\begin{code}' result.concat(raw_code) result << '\end{code}' rescue CodeInclusionException => e code_error(e.) end |