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?, #formatting_options, #has_attributes?, #has_default_attributes?, #has_language?, hide_default_attributes!, hide_default_attributes?, #initialize, #initialize_copy, #inspect, #match?, match?, parse, parse!, #save_to, show_default_attributes!, #tags, #textnode?, types

Methods included from PrettyPrinter

#pretty_print, #tags, #to_xml

Methods included from Treelike

#<<, #add_child, #add_children, #ancestors, #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

Returns:

  • (Boolean)


12
13
14
# File 'lib/csl/style/choose.rb', line 12

def matches?(nodename)
  nodename.to_s =~ /^if(-else)?|else$/
end

Instance Method Details

#conditionsObject



17
18
19
20
21
# File 'lib/csl/style/choose.rb', line 17

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



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

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