Class: Flms::Page
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- Flms::Page
- Defined in:
- app/models/flms/page.rb
Instance Method Summary collapse
-
#blocks_to_display_with_offsets ⇒ Object
Returns an array containing blocks and associated scroll offsets for display.
-
#ordered_blocks_pages ⇒ Object
Returns the blocks_pages of this page, in the right order to display them.
-
#position_for_block(block_id) ⇒ Object
Returns the BlocksPage object for the given block on this page.
-
#to_param ⇒ Object
For creating URLs.
Instance Method Details
#blocks_to_display_with_offsets ⇒ Object
Returns an array containing blocks and associated scroll offsets for display.
27 28 29 30 31 32 33 34 35 |
# File 'app/models/flms/page.rb', line 27 def blocks_to_display_with_offsets scroll_offset = 0 blocks_for_display = [] blocks_pages.ordered.is_active.each do |block_page| blocks_for_display << { block: block_page.block, scroll_offset: scroll_offset } scroll_offset += block_page.block.scroll_duration end blocks_for_display end |
#ordered_blocks_pages ⇒ Object
Returns the blocks_pages of this page, in the right order to display them.
12 13 14 |
# File 'app/models/flms/page.rb', line 12 def ordered_blocks_pages blocks_pages.ordered end |
#position_for_block(block_id) ⇒ Object
Returns the BlocksPage object for the given block on this page.
17 18 19 |
# File 'app/models/flms/page.rb', line 17 def position_for_block block_id blocks_pages.where(block_id: block_id).first end |
#to_param ⇒ Object
For creating URLs.
22 23 24 |
# File 'app/models/flms/page.rb', line 22 def to_param url end |