Class: CSL::Nodes::DatePart
- Inherits:
-
Node
- Object
- Node
- CSL::Nodes::DatePart
show all
- Defined in:
- lib/csl/nodes.rb
Instance Attribute Summary
Attributes inherited from Node
#style
#node_name, #parent
#attributes, #key_filter, #value_filter
Instance Method Summary
collapse
Methods inherited from Node
#copy, #evaluate, format_on, #initialize, #localized_date_parts, #localized_options, #localized_terms, #merge, #parse, #reverse_merge, #to_s
#add_children, #ancestors, #ancestors!, #children, #depth, #descendants, #descendants!, #each, #find_children_by_name, #has_children?, included, #name, #root, #root!, #root?
#[], #[]=, included, #merge, #reverse_merge
Instance Method Details
#gender(date, processor) ⇒ Object
616
617
618
|
# File 'lib/csl/nodes.rb', line 616
def gender(date, processor)
localized_terms("month-%02d" % date.month, processor).gender
end
|
#process(date, processor) ⇒ Object
564
565
566
567
568
|
# File 'lib/csl/nodes.rb', line 564
def process(date, processor)
send(['process', self['name']].join('_'), date, processor)
rescue Exception => e
handle_processing_error(e, data, processor)
end
|
#process_day(date, processor) ⇒ Object
603
604
605
606
607
608
609
610
611
612
613
614
|
# File 'lib/csl/nodes.rb', line 603
def process_day(date, processor)
return '' if date.day.nil?
case
when form == 'ordinal'
locale(processor).ordinalize(date.day, 'gender-form' => gender(date, processor))
when form == 'numeric-leading-zeros'
"%02d" % date.day
else date.day.to_s
end
end
|
#process_month(date, processor) ⇒ Object
582
583
584
585
586
587
588
589
590
591
592
593
594
|
# File 'lib/csl/nodes.rb', line 582
def process_month(date, processor)
return process_season(date, processor) if date.has_season?
return '' if date.month.nil?
case
when form == 'numeric'
date.month.to_s
when form == 'numeric-leading-zeros'
"%02d" % date.month
else
localized_terms("month-%02d" % date.month, processor).to_s(attributes)
end
end
|
#process_season(date, processor) ⇒ Object
596
597
598
599
600
601
|
# File 'lib/csl/nodes.rb', line 596
def process_season(date, processor)
season = date.season.to_s
season = date.month.to_s if season.match(/true|always|yes/i)
season = localized_terms('season-%02d' % season.to_i, processor).to_s if season.match(/0?[1-4]/)
season
end
|
#process_year(date, processor) ⇒ Object
572
573
574
575
576
577
578
579
580
|
# File 'lib/csl/nodes.rb', line 572
def process_year(date, processor)
return '' if date.year.nil?
year = date.year.abs.to_s
year = year[-2..-1] if form == 'short'
year = [year, localized_terms('ad')].join if date.ad?
year = [year, localized_terms('bc')].join if date.bc?
year
end
|