Class: Arrow::Template::TimeDeltaDirective

Inherits:
CallDirective show all
Defined in:
lib/arrow/template/timedelta.rb

Overview

The Arrow::Template::TimeDeltaDirective class, a derivative of Arrow::Template::CallDirective. This plugin defines the ‘timedelta’ template directive.

Syntax

<?timedelta process.uptime ?>

Authors

:include: LICENSE

Please see the file LICENSE in the ‘docs’ directory for licensing details.

Constant Summary collapse

MINUTES =

Approximate Time Constants (in seconds)

60
HOURS =
60  * MINUTES
DAYS =
24  * HOURS
WEEKS =
7   * DAYS
MONTHS =
30  * DAYS
YEARS =
365.25 * DAYS

Constants inherited from CallDirective

CallDirective::SVNId, CallDirective::SVNRev

Constants inherited from AttributeDirective

AttributeDirective::SVNId, AttributeDirective::SVNRev

Constants inherited from Directive

Directive::SVNId, Directive::SVNRev

Constants inherited from Node

Node::SVNId, Node::SVNRev

Constants included from HTMLUtilities

HTMLUtilities::ARRAY_HTML_CONTAINER, HTMLUtilities::HASH_HTML_CONTAINER, HTMLUtilities::HASH_PAIR_HTML, HTMLUtilities::IMMEDIATE_OBJECT_HTML_CONTAINER, HTMLUtilities::IVAR_HTML_FRAGMENT, HTMLUtilities::OBJECT_HTML_CONTAINER, HTMLUtilities::THREAD_DUMP_KEY

Instance Attribute Summary

Attributes inherited from AttributeDirective

#format, #methodchain, #name

Attributes inherited from Node

#type

Instance Method Summary collapse

Methods inherited from AttributeDirective

allows_format?, #before_rendering, #initialize, #inspect, #is_rendering_node?, #to_html

Methods inherited from Directive

create, derivativeDirs, #initialize, #inspect, #to_html

Methods inherited from Node

#add_to_template, #initialize, #inspect, #is_rendering_node?, #to_a, #to_html, #to_s

Methods included from HTMLUtilities

escape_html, make_html_for_object, make_object_html_wrapper

Methods inherited from Object

deprecate_class_method, deprecate_method, inherited

Constructor Details

This class inherits a constructor from Arrow::Template::AttributeDirective

Instance Method Details

#render(template, scope) ⇒ Object

Render the content and return it as URL-escaped text.



40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
# File 'lib/arrow/template/timedelta.rb', line 40

def render( template, scope )
	rawary = super
	rary = []

	# Try our best to skip debugging comments
	if template._config[:debuggingComments]
		rary.push( rawary.shift ) if /^<!--.*-->$/ =~ rawary.first
	end

	rawary.each do |line|
		rary << time_delta_string( line.to_i )
	end

	return rary
end