Class: Microformats::Calendar
- Inherits:
-
Object
- Object
- Microformats::Calendar
- Includes:
- FormattingHelpers
- Defined in:
- lib/calendar.rb
Instance Method Summary collapse
-
#event(opts = {}, &block) ⇒ Object
Creates a vEvent with the given options and a block.
-
#initialize(template) ⇒ Calendar
constructor
A new instance of Calendar.
-
#run(opts = {}, &block) ⇒ Object
You can directly initialize and run this class, but it’s easier to use the Microformats::Helpers#vcalendar helper method.
Methods included from FormattingHelpers
#combine_class_names, #concat, #concat_tag, #content_tag, #encode_time, #humanize_time, #merge_html_attrs
Constructor Details
#initialize(template) ⇒ Calendar
Returns a new instance of Calendar.
4 5 6 7 |
# File 'lib/calendar.rb', line 4 def initialize(template) @template = template @default_tag = :span end |
Instance Method Details
#event(opts = {}, &block) ⇒ Object
Creates a vEvent with the given options and a block.
OPTIONS:
-
:tag - The HTML wrapper element (defaults to :div)
-
Any other passed options will be treated as HTML attributes.
EXAMPLE:
<% calendar.event :id => 'my_event' do |event| %>
This event is called <%= event.name "Cool Event" %>.
<% end %>
35 36 37 38 39 |
# File 'lib/calendar.rb', line 35 def event(opts = {}, &block) ev = Microformats::Event.new(@template) opts[:class] = combine_class_names('vevent', opts[:class]) ev.run(opts, &block) end |
#run(opts = {}, &block) ⇒ Object
You can directly initialize and run this class, but it’s easier to use the Microformats::Helpers#vcalendar helper method.
OPTIONS:
-
:tag - The HTML wrapper element (defaults to :div)
-
Any other passed options will be treated as HTML attributes.
16 17 18 19 20 21 22 |
# File 'lib/calendar.rb', line 16 def run(opts = {}, &block) opts[:class] = combine_class_names('vcalendar', opts[:class]) opts[:tag] ||= :div concat_tag(opts) do block.call(self) end end |