Class: HtmlGrid::Component
- Inherits:
-
Object
- Object
- HtmlGrid::Component
show all
- Defined in:
- lib/ydim/html/view/htmlgrid.rb
Constant Summary
collapse
{
"Cache-Control" => "no-cache, max-age=3600, must-revalidate",
'Content-Type' => 'text/html; charset=ISO-8859-1',
}
Class Method Summary
collapse
Instance Method Summary
collapse
Class Method Details
.escaped(*names) ⇒ Object
20
21
22
23
24
25
26
|
# File 'lib/ydim/html/view/htmlgrid.rb', line 20
def escaped(*names)
names.each { |name|
define_method(name) { |model|
number_format escape(model.send(name))
}
}
end
|
.links(event, *names) ⇒ Object
27
28
29
30
31
32
33
34
35
36
37
|
# File 'lib/ydim/html/view/htmlgrid.rb', line 27
def links(event, *names)
names.each { |name|
define_method(name) { |model|
link = HtmlGrid::Link.new(name, model, @session, self)
args = {:unique_id => model.unique_id}
link.href = @lookandfeel._event_url(event, args)
link.value = model.send(name)
link
}
}
end
|
Instance Method Details
#escape(value) ⇒ Object
39
40
41
|
# File 'lib/ydim/html/view/htmlgrid.rb', line 39
def escape(value)
CGI.escape(format(value))
end
|
42
43
44
45
46
47
48
49
|
# File 'lib/ydim/html/view/htmlgrid.rb', line 42
def format(value)
case value
when Float
sprintf("%1.#{self.precision}f", value)
else
value.to_s
end
end
|
50
51
52
53
54
|
# File 'lib/ydim/html/view/htmlgrid.rb', line 50
def number_format(string)
string.reverse.gsub(/\d{3}(?=\d)(?!\d*\.)/) do |match|
match << "'"
end.reverse
end
|
#precision ⇒ Object
55
56
57
58
59
60
61
62
|
# File 'lib/ydim/html/view/htmlgrid.rb', line 55
def precision
mdl = @session.state.model
if(mdl.respond_to?(:precision))
mdl.precision
else
2
end
end
|