Class: CSL::Style::Choose::Block

Inherits:
Node show all
Defined in:
lib/csl/style/choose.rb

Instance Attribute Summary

Attributes inherited from Node

#attributes

Attributes included from Treelike

#children, #nodename, #parent

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Node

#<=>, #attribute?, #attributes?, #attributes_for, constantize, create, create_attributes, #custom_attributes, #deep_copy, #default_attribute?, default_attributes, #default_attributes, #each, #exact_match?, #format_page_ranges?, #formatting_options, #has_attributes?, #has_default_attributes?, #has_language?, hide_default_attributes!, hide_default_attributes?, #initialize, #initialize_copy, #inspect, match?, #match?, #merge!, #page_range_format, parse, parse!, #quotes?, #reverse_merge!, #save_to, show_default_attributes!, #strip_periods?, #tags, #textnode?, types

Methods included from Extensions::Nesting

#nesting

Methods included from PrettyPrinter

#pretty_print, #tags, #to_xml

Methods included from Treelike

#<<, #add_child, #add_children, #ancestors, #closest, #delete_child, #delete_children, #depth, #descendants, #each_ancestor, #each_child, #each_descendant, #each_sibling, #empty?, #find_child, #find_children, #has_children?, #root, #root?, #siblings, #unlink

Constructor Details

This class inherits a constructor from CSL::Node

Class Method Details

.matches?(nodename) ⇒ Boolean



14
15
16
# File 'lib/csl/style/choose.rb', line 14

def matches?(nodename)
  nodename === ':if' || nodename === ':elseif' || nodename === ':else'
end

Instance Method Details

#conditionsObject



19
20
21
22
23
# File 'lib/csl/style/choose.rb', line 19

def conditions
  attributes_for(*Schema.attr(:conditionals)).map do |name, values|
    extract_type_and_matcher_from(name) << values.to_s.split(/\s+/)
  end
end

#matcher(match = attributes[:match]) ⇒ Object



25
26
27
28
29
30
31
32
33
34
# File 'lib/csl/style/choose.rb', line 25

def matcher(match = attributes[:match])
  case match.to_s
  when 'any'
    :any?
  when 'none'
    :none?
  else
    :all?
  end
end