Class: Configuration::OutputText
- Inherits:
-
Scope
- Object
- Scope
- Configuration::OutputText
show all
- Defined in:
- lib/httpimagestore/configuration/handler.rb
Class Method Summary
collapse
Instance Method Summary
collapse
Methods inherited from Scope
node_parsers, #parse, register_node_parser
Constructor Details
#initialize(text, status, cache_control) ⇒ OutputText
Returns a new instance of OutputText.
232
233
234
235
236
|
# File 'lib/httpimagestore/configuration/handler.rb', line 232
def initialize(text, status, cache_control)
@text = RubyStringTemplate.new(text || fail("no text?!"))
@status = status || 200
@cache_control = cache_control
end
|
Class Method Details
.match(node) ⇒ Object
221
222
223
|
# File 'lib/httpimagestore/configuration/handler.rb', line 221
def self.match(node)
node.name == 'output_text'
end
|
.parse(configuration, node) ⇒ Object
225
226
227
228
229
230
|
# File 'lib/httpimagestore/configuration/handler.rb', line 225
def self.parse(configuration, node)
configuration.output and raise StatementCollisionError.new(node, 'output')
text = node.grab_values('text').first
status, cache_control = *node.grab_attributes('status', 'cache-control')
configuration.output = OutputText.new(text, status || 200, cache_control)
end
|
Instance Method Details
#realize(request_state) ⇒ Object
238
239
240
241
242
243
244
245
246
247
|
# File 'lib/httpimagestore/configuration/handler.rb', line 238
def realize(request_state)
status = @status
text = @text.render(request_state)
cache_control = @cache_control
request_state.output do
res['Cache-Control'] = cache_control if cache_control
write_plain status.to_i, text.to_s
end
end
|