Class: When::CalendarNote::DiscordianWeek

Inherits:
Week show all
Defined in:
lib/when_exe/region/discordian.rb

Overview

Discordian Note

Constant Summary collapse

Notes =
[When::BasicTypes::M17n, [
  "namespace:[en=https://en.wiktionary.org/wiki/]",
  "locale:[=en:, ja=ja:]",
  "names:[Discordian]",

  # Notes for year ----------------------------
  [When::BasicTypes::M17n,
    "names:[note for year=, 年の暦注=, *year]"
  ],

  # Notes for month ----------------------------
  [When::BasicTypes::M17n,
    "names:[note for month=, 月の暦注=, *month]",
    [When::BasicTypes::M17n,
      "names:[month name=en:Month, 月の名前=ja:%%<月_(暦)>, zh:該月的名稱=, *alias:Month=]",
      "[Chaos=en:chaos            ]",
      "[Discord=en:discord        ]",
      "[Confusion=en:confusion    ]",
      "[Bureaucracy=en:bureaucracy]",
      "[The Aftermath=en:aftermath]"
    ]
  ],

  # Notes for day ----------------------------
  [When::BasicTypes::M17n,
    "names:[note for day=, 日の暦注=, *day]",
    [When::BasicTypes::M17n,
      "names:[Five day week=, 五日週=, zh:五日週=, *alias:Week=]",
      [DayOfWeek, "label:[Sweetmorn=      ]", {'delta'=>5}],
      [DayOfWeek, "label:[Boomtime=       ]", {'delta'=>5}],
      [DayOfWeek, "label:[Pungenday=      ]", {'delta'=>5}],
      [DayOfWeek, "label:[Prickle-Prickle=]", {'delta'=>5}],
      [DayOfWeek, "label:[Setting Orange= ]", {'delta'=>5}],
      [DayOfWeek, "label:[Out of Week=    ]", {'delta'=>1461}]
    ],

    [When::BasicTypes::M17n,
      "names:[Holyday=, 祝日=, zh:祝日=]",
      "[St. Tib's Day=]", # 02-29 St. Tib's Day
      "[Mungday=      ]", # 01-05 Chaos 5
      "[Chaoflux=     ]", # 02-19 Chaos 50
      "[Mojoday=      ]", # 03-19 Discord 5
      "[Discoflux=    ]", # 05-03 Discord 50
      "[Syaday=       ]", # 05-31 Confusion 5
      "[Confuflux=    ]", # 07-15 Confusion 50
      "[Zaraday=      ]", # 08-12 Bureaucracy 5
      "[Bureflux=     ]", # 09-26 Bureaucracy 50
      "[Maladay=      ]", # 10-24 The Aftermath 5
      "[Afflux=       ]"  # 12-08 The Aftermath 50
    ],

    "[Common_Week=]"
  ]
]]

Constants inherited from When::CalendarNote

Bahai, CalendarDepend, Chinese, CommonWithRokuyo, CommonWithSovietFiveDay, CommonWithSovietSixDay, Default, Javanese, JulianDay, Mayan, Tibetan, Yis

Constants included from Namespace

Namespace::DC, Namespace::DCQ, Namespace::DCT, Namespace::FOAF, Namespace::OWL, Namespace::RDF, Namespace::RDFC, Namespace::RDFS, Namespace::RSS, Namespace::XSD

Instance Attribute Summary

Attributes inherited from When::CalendarNote

#event

Attributes inherited from TM::ReferenceSystem

#domain_of_validity, #position

Attributes inherited from BasicTypes::Object

#label

Attributes included from Parts::Resource

#child, #keys, #locale, #namespace

Instance Method Summary collapse

Methods inherited from Week

#common_week

Methods inherited from When::CalendarNote

#copy, #day, #duration, #enum_for, #include?, #month, #note?, #notes, #year

Methods inherited from TM::ReferenceSystem

#domain, #name

Methods included from Parts::Resource

#[], #^, _instance, _setup_, _setup_info, base_uri, #each, #enum_for, #hierarchy, #include?, #included?, #iri, #leaf?, #m17n, #map, #parent, #registered?, root_dir

Methods included from Parts::Resource::Pool

#[], #[]=, #_setup_

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class When::Parts::Resource

Instance Method Details

#holyday(date) ⇒ String

Holyday

Parameters:

Returns:



138
139
140
141
142
143
144
145
146
147
148
149
# File 'lib/when_exe/region/discordian.rb', line 138

def holyday(date)
  date    = _to_date_for_note(date)
  y, m, d = date.cal_date
  index =
    case +d
    when  5 ;  1
    when 50 ;  2
    else    ;  d * 0 - 1
    end
  return nil if index == -1
  When.CalendarNote('DiscordianWeek/Notes::day::Holyday::*')[(m-1)*2+index]
end

#sweetmorn(date, parameter = nil) ⇒ When::TM::TemporalPosition

Just or last sweetmorn

Parameters:

Returns:



92
93
94
95
96
97
98
99
100
# File 'lib/when_exe/region/discordian.rb', line 92

def sweetmorn(date, parameter=nil)
  date  = _to_date_for_note(date)
  y,m,d = date.cal_date
  date -= When::P1D if date.length(When::MONTH) == 74 && +d == 60
  dow   = ((m-1)*73+d*1-1) % 5
  date -= When::P1D * dow unless dow == 0
  date.events = [@days_of_week[0]]
  date
end

#week(date, base = nil) ⇒ String

Erisian week

Parameters:

Returns:



109
110
111
112
113
114
115
116
# File 'lib/when_exe/region/discordian.rb', line 109

def week(date, base=nil)
  date   = _to_date_for_note(date)
  y,m,d  = date.cal_date
  dow    = d*0 == 0 ? ((m-1)*73+d*1-1) % 5 : 5
  length = (base || date).length(When::MONTH) == 73 ? 5 : 6
  index  = length == 5 ? dow : IndexOfWeek[dow]
  {:value=>@days_of_week[dow], :position=>[index,length]}
end

#week_labels(date) ⇒ Array<When::CalendarNote::Week::DayOfWeek>

Week labels



125
126
127
128
129
130
# File 'lib/when_exe/region/discordian.rb', line 125

def week_labels(date)
  date = _to_date_for_note(date)
  date.length(When::MONTH) == 73 ?
    @days_of_week.child[0...5] :
    @days_of_week.child[0...4] + [@days_of_week.child[5]] + [@days_of_week.child[4]]
end