Class: Bureaucrat::Widgets::RadioFieldRenderer
- Inherits:
-
Object
- Object
- Bureaucrat::Widgets::RadioFieldRenderer
show all
- Includes:
- Utils
- Defined in:
- lib/bureaucrat/widgets.rb
Constant Summary
Constants included
from Utils
Utils::ESCAPES
Instance Method Summary
collapse
Methods included from Utils
#blank_value?, #conditional_escape, #escape, #flatatt, #format_string, #make_bool, #make_float, #mark_safe, #pretty_name
Constructor Details
#initialize(name, value, attrs, choices) ⇒ RadioFieldRenderer
Returns a new instance of RadioFieldRenderer.
456
457
458
459
460
461
|
# File 'lib/bureaucrat/widgets.rb', line 456
def initialize(name, value, attrs, choices)
@name = name
@value = value
@attrs = attrs
@choices = choices
end
|
Instance Method Details
#[](idx) ⇒ Object
469
470
471
472
|
# File 'lib/bureaucrat/widgets.rb', line 469
def [](idx)
choice = @choices[idx]
RadioInput.new(@name, @value, @attrs.dup, choice, idx)
end
|
#each ⇒ Object
463
464
465
466
467
|
# File 'lib/bureaucrat/widgets.rb', line 463
def each
@choices.each_with_index do |choice, i|
yield RadioInput.new(@name, @value, @attrs.dup, choice, i)
end
end
|
#render ⇒ Object
478
479
480
481
482
|
# File 'lib/bureaucrat/widgets.rb', line 478
def render
list = []
each {|radio| list << "<li>#{radio}</li>"}
mark_safe("<ul>\n#{list.join("\n")}\n</ul>")
end
|
#to_s ⇒ Object
474
475
476
|
# File 'lib/bureaucrat/widgets.rb', line 474
def to_s
render
end
|