class CSL::Style

Attributes

default[RW]
errors[R]
macros[R]
name[RW]

Public Class Methods

load(input = nil) click to toggle source
Calls superclass method CSL::Loader#load
# File lib/csl/style.rb, line 20
def load(input = nil)
  super(input || Style.default)
end
new(attributes = {}) { |self| ... } click to toggle source
Calls superclass method CSL::Node::new
# File lib/csl/style.rb, line 52
def initialize(attributes = {})
  super(attributes, &nil)
  children[:locale], children[:macro], @macros, @errors = [], [], {}, []

  yield self if block_given?
end

Public Instance Methods

added_child(node) click to toggle source

@override

# File lib/csl/style.rb, line 60
def added_child(node)
  delegate = :"added_#{node.nodename}"
  send delegate, node if respond_to?(delegate, true)
  node
end
deleted_child(node) click to toggle source

@override

# File lib/csl/style.rb, line 67
def deleted_child(node)
  delegate = :"deleted_#{node.nodename}"
  send delegate, node if respond_to?(delegate, true)
  node
end
demote_non_dropping_particle() click to toggle source
# File lib/csl/style.rb, line 119
def demote_non_dropping_particle
  attributes[:'demote-non-dropping-particle']
end
Also aliased as: demote_particle
demote_non_dropping_particle?() click to toggle source
# File lib/csl/style.rb, line 124
def demote_non_dropping_particle?
  attribute?(:'demote-non-dropping-particle')
end
Also aliased as: demote_particle?
demote_particle()
demote_particle?()
has_page_range_format?() click to toggle source
# File lib/csl/style.rb, line 133
def has_page_range_format?
  attribute?(:'page-range-format')
end
id() click to toggle source

@return [String] the style's id

# File lib/csl/style.rb, line 89
def id
  return unless info.has_id?
  info.id.to_s
end
independent?() click to toggle source
# File lib/csl/style.rb, line 110
def independent?
  !dependent?
end
independent_parent() click to toggle source
# File lib/csl/style.rb, line 114
def independent_parent
  return unless dependent?
  load_related_style_from independent_parent_link
end
info() click to toggle source
# File lib/csl/style.rb, line 82
def info
  children[:info] ||= Info.new
end
initialize_without_hyphen?() click to toggle source
# File lib/csl/style.rb, line 129
def initialize_without_hyphen?
  attribute?(:'initialize-with-hyphen') && !attributes[:'initialize-with-hyphen']
end
page_range_format() click to toggle source
# File lib/csl/style.rb, line 137
def page_range_format
  attributes[:'page-range-format']
end
template() click to toggle source

@return [Style] the style's template

# File lib/csl/style.rb, line 103
def template
  return unless has_template?
  load_related_style_from template_link
end
title() click to toggle source

@return [String] the style's title

# File lib/csl/style.rb, line 95
def title
  return unless info.has_title?
  info.title.to_s
end
valid?() click to toggle source
# File lib/csl/style.rb, line 77
def valid?
  validate.empty?
end
validate() click to toggle source
# File lib/csl/style.rb, line 73
def validate
  @errors = Schema.validate self
end

Private Instance Methods

added_macro(node) click to toggle source
# File lib/csl/style.rb, line 153
def added_macro(node)
  unless node.attribute?(:name)
    raise ValidationError,
      "failed to register macro #{node.inspect}: name attribute missing"
  end

  if macros.key?(node[:name])
    raise ValidationError,
      "failed to register macro #{node.inspect}: duplicate name"
  end

  macros[node[:name]] = node
end
deleted_macro(node) click to toggle source
# File lib/csl/style.rb, line 167
def deleted_macro(node)
  macros.delete node[:name]
end
preamble() click to toggle source
# File lib/csl/style.rb, line 143
def preamble
  Schema.preamble.dup
end