Class: CSL::Locale::Date

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

Overview

A localized Date comprises a set of formatting rules for dates.

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:



13
14
15
16
17
18
# File 'lib/csl/locale/date.rb', line 13

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

  yield self if block_given?
end

Instance Method Details

#added_to(node) ⇒ Object

Raises:



20
21
22
# File 'lib/csl/locale/date.rb', line 20

def added_to(node)
  raise ValidationError, "parent must be locale node: was #{node.inspect}" unless node.is_a?(Locale)
end

#delimiterObject



24
25
26
# File 'lib/csl/locale/date.rb', line 24

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

#formObject



32
33
34
# File 'lib/csl/locale/date.rb', line 32

def form
  attributes[:form].to_s
end

#has_date_parts?Boolean Also known as: has_parts?

Returns:

  • (Boolean)


44
45
46
# File 'lib/csl/locale/date.rb', line 44

def has_date_parts?
  !date_parts.empty?
end

#has_form?Boolean

Returns:

  • (Boolean)


28
29
30
# File 'lib/csl/locale/date.rb', line 28

def has_form?
  attribute?(:form)
end

#numeric?Boolean

Returns:

  • (Boolean)


40
41
42
# File 'lib/csl/locale/date.rb', line 40

def numeric?
  attributes[:form].to_s =~ /^numeric$/i
end

#text?Boolean

Returns:

  • (Boolean)


36
37
38
# File 'lib/csl/locale/date.rb', line 36

def text?
  !numeric?
end