Module: EPUB::Publication::FixedLayout::Rendition

Included in:
ContentDocumentMixin, ItemMixin, ItemrefMixin, MetadataMixin
Defined in:
lib/epub/publication/fixed_layout.rb

Instance Method Summary collapse

Instance Method Details

#def_rendition_layout_methodsObject



39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
# File 'lib/epub/publication/fixed_layout.rb', line 39

def def_rendition_layout_methods
  property = 'layout'
  RENDITION_PROPERTIES[property].each do |value|
    method_name_base = value.gsub('-', '_')
    writer_name = "#{method_name_base}="
    define_method writer_name do |new_value|
      new_prop = new_value ? value : values.find {|l| l != value}
      __send__ "rendition_#{property}=", new_prop
    end

    maker_name = "make_#{method_name_base}"
    define_method maker_name do
      __send__ "rendition_#{property}=", value
    end
    destructive_method_name = "#{method_name_base}!"
    alias_method destructive_method_name, maker_name

    predicate_name = "#{method_name_base}?"
    define_method predicate_name do
      __send__("rendition_#{property}") == value
    end
  end
end

#def_rendition_methodsObject

Note:

Call after defining #rendition_xxx and #renditionn_xxx=



31
32
33
34
35
36
37
# File 'lib/epub/publication/fixed_layout.rb', line 31

def def_rendition_methods
  RENDITION_PROPERTIES.each_key do |property|
    alias_method property, "rendition_#{property}"
    alias_method "#{property}=", "rendition_#{property}="
  end
  def_rendition_layout_methods
end