Class: CSL::Style

Inherits:
Node show all
Extended by:
Loader
Defined in:
lib/csl/style.rb,
lib/csl/style/date.rb,
lib/csl/style/text.rb,
lib/csl/style/group.rb,
lib/csl/style/label.rb,
lib/csl/style/macro.rb,
lib/csl/style/names.rb,
lib/csl/style/choose.rb,
lib/csl/style/layout.rb,
lib/csl/style/number.rb,
lib/csl/style/citation.rb,
lib/csl/style/bibliography.rb

Defined Under Namespace

Classes: Bibliography, Choose, Citation, Date, DatePart, EtAl, Group, Label, Layout, Macro, Name, NamePart, Names, Number, Substitute, Text

Class Attribute Summary collapse

Instance Attribute Summary collapse

Attributes included from Loader

#extension, #prefix, #root

Attributes inherited from Node

#attributes

Attributes included from Treelike

#children, #nodename, #parent

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Loader

extend_name, extend_path, list, load

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_copy, #inspect, #match?, match?, matches?, 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

#initialize(attributes = {}) {|_self| ... } ⇒ Style

Returns a new instance of Style.

Yields:

  • (_self)

Yield Parameters:

  • _self (CSL::Style)

    the object that the method was called on



51
52
53
54
55
56
# File 'lib/csl/style.rb', line 51

def initialize(attributes = {})
  super(attributes, &nil)
  children[:locale], children[:macro], @macros, @errors = [], [], {}, []

  yield self if block_given?
end

Class Attribute Details

.defaultObject

Returns the value of attribute default.



16
17
18
# File 'lib/csl/style.rb', line 16

def default
  @default
end

Instance Attribute Details

#errorsObject (readonly)

Returns the value of attribute errors.



35
36
37
# File 'lib/csl/style.rb', line 35

def errors
  @errors
end

#macrosObject (readonly)

Returns the value of attribute macros.



35
36
37
# File 'lib/csl/style.rb', line 35

def macros
  @macros
end

Class Method Details

.load(input = Style.default) ⇒ Object



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

def load(input = Style.default)
  super
end

Instance Method Details

#added_child(node) ⇒ Object



59
60
61
62
63
# File 'lib/csl/style.rb', line 59

def added_child(node)
  delegate = :"added_#{node.nodename}"
  send delegate, node if respond_to?(delegate, true)
  node
end

#deleted_child(node) ⇒ Object



66
67
68
69
70
# File 'lib/csl/style.rb', line 66

def deleted_child(node)
  delegate = :"deleted_#{node.nodename}"
  send delegate, node if respond_to?(delegate, true)
  node
end

#idString

Returns the style’s id.

Returns:

  • (String)

    the style’s id



87
88
89
90
# File 'lib/csl/style.rb', line 87

def id
  return unless info.has_id?
  info.id.to_s
end

#independent?Boolean

Returns:

  • (Boolean)


108
109
110
# File 'lib/csl/style.rb', line 108

def independent?
  !dependent?
end

#independent_parentObject



112
113
114
115
# File 'lib/csl/style.rb', line 112

def independent_parent
  return unless dependent?
  load_related_style_from independent_parent_link
end

#infoObject



80
81
82
# File 'lib/csl/style.rb', line 80

def info
  children[:info] ||= Info.new
end

#templateStyle

Returns the style’s template.

Returns:

  • (Style)

    the style’s template



101
102
103
104
# File 'lib/csl/style.rb', line 101

def template
  return unless has_template?
  load_related_style_from template_link
end

#titleString

Returns the style’s title.

Returns:

  • (String)

    the style’s title



93
94
95
96
# File 'lib/csl/style.rb', line 93

def title
  return unless info.has_title?
  info.title.to_s
end

#valid?Boolean

Returns:

  • (Boolean)


76
77
78
# File 'lib/csl/style.rb', line 76

def valid?
  validate.empty?
end

#validateObject



72
73
74
# File 'lib/csl/style.rb', line 72

def validate
  @errors = Schema.validate self
end