Class: CSL::Style::Date

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

Instance Attribute Summary

Attributes inherited from Node

#attributes

Attributes included from Treelike

#children, #nodename, #parent

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

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

Returns a new instance of Date.

Yields:

  • (_self)

Yield Parameters:



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

def initialize(attributes = {})
  super(attributes, &nil)
  children[:'date-part'] = []

  yield self if block_given?
end

Instance Method Details

#date_parts_filterArray<String> Also known as: parts_filter

Returns the localized date parts to be used.

Returns:

  • (Array<String>)

    the localized date parts to be used



25
26
27
# File 'lib/csl/style/date.rb', line 25

def date_parts_filter
  attributes[:'date-parts'].to_s.split(/-/)
end

#delimiterObject



30
31
32
# File 'lib/csl/style/date.rb', line 30

def delimiter
  attributes.fetch(:delimiter, '')
end

#formObject



47
48
49
# File 'lib/csl/style/date.rb', line 47

def form
  attributes[:form].to_s
end

#has_date_parts?Boolean Also known as: has_parts?

Returns:

  • (Boolean)


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

def has_date_parts?
  !date_parts.empty?
end

#has_form?Boolean Also known as: localized?

Returns:

  • (Boolean)


42
43
44
# File 'lib/csl/style/date.rb', line 42

def has_form?
  attribute?(:form)
end

#has_overrides?Boolean

Returns:

  • (Boolean)


64
65
66
# File 'lib/csl/style/date.rb', line 64

def has_overrides?
  localized? && has_parts?
end

#has_variable?Boolean

Returns:

  • (Boolean)


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

def has_variable?
  attribute?(:variable)
end

#numeric?Boolean

Returns:

  • (Boolean)


51
52
53
# File 'lib/csl/style/date.rb', line 51

def numeric?
  form =~ /^numeric$/i
end

#text?Boolean

Returns:

  • (Boolean)


55
56
57
# File 'lib/csl/style/date.rb', line 55

def text?
  form =~ /^text$/i
end

#variableObject



38
39
40
# File 'lib/csl/style/date.rb', line 38

def variable
  attributes[:variable]
end