Class: String
- Inherits:
-
Object
- Object
- String
- Defined in:
- lib/when_exe/core/extension.rb,
lib/when_exe/core/compatibility.rb
Overview
Ruby .8.x 系のためのための互換性確保用コード
Direct Known Subclasses
Instance Method Summary collapse
-
#^(other) ⇒ When::TM::TemporalPosition の “^”演算結果
self をWhen.exe Standard Expression とみなして When::TM::TemporalPosition を生成し“^”演算を実行.
-
#calendar ⇒ When::TM::Calendar
(also: #to_calendar)
self をプレフィクス ‘_c:’ を省略した IRI とみなして When::TM::Calendar を取得.
-
#calendar_era ⇒ When::TM::CalendarEra
(also: #to_calendar_era)
self をプレフィクス ‘_e:’ を省略した IRI とみなして When::TM::CalendarEra を取得.
-
#calendar_note ⇒ When::TM::CalendarNote
(also: #to_calendar_note)
self をプレフィクス ‘_c:’ を省略した IRI とみなして When::TM::CalendarNote を取得.
-
#encode(code) ⇒ String
encode.
-
#calendar_era(options = {}) ⇒ Array<When::TM::CalendarEra>
(also: #to_era)
self を検索する暦年代とみなして登録された When::TM::CalendarEraを検索.
-
#ideographic_unification(pattern = When::Parts::Locale._unification) ⇒ String
包摂リストに登録されている文字を包摂する.
-
#m17n ⇒ When::BasicTypes::M17n
self をプレフィクス ‘_m:’ を省略した IRI とみなして When::BasicTypes::M17n を取得.
-
#ord ⇒ Integer
文字列の先頭文字のコードを取得する (多バイト文字非対応).
-
#resource(namespace = nil) ⇒ When::Parts::Resource
(also: #to_resource)
self を IRI とみなして When::Parts::Resource を取得.
-
#to_m17n ⇒ When::BasicTypes::M17n
self を When::BasicTypes::M17n に変換する.
-
#to_month_name ⇒ When::BasicTypes::M17n
(also: #month_name)
月名.
-
#to_pair ⇒ When::Coordinates::Pair
(also: #pair)
self を幹と枝の要素と解釈してWhen::Coordinates::Pair を生成.
-
#to_r ⇒ Numeric
to_r(もどき).
-
#to_residue ⇒ When::Coordinates::Residue
(also: #residue, #day_of_week)
曜日(剰余類).
-
#translate(loc = '') ⇒ String
(also: #/)
特定 locale に対応した文字列の取得.
-
#when?(options = {}) ⇒ When::TM::TemporalPosition
(also: #tm_position, #to_tm_position)
self をWhen.exe Standard Expression とみなして When::TM::TemporalPosition を生成.
Instance Method Details
#^(other) ⇒ When::TM::TemporalPosition の “^”演算結果
core/extension
self をWhen.exe Standard Expression とみなして When::TM::TemporalPosition を生成し“^”演算を実行
360 361 362 |
# File 'lib/when_exe/core/extension.rb', line 360 def ^(other) When::TM::TemporalPosition._instance(self, {}) ^ other end |
#calendar ⇒ When::TM::Calendar Also known as: to_calendar
core/extension
self をプレフィクス ‘_c:’ を省略した IRI とみなして When::TM::Calendar を取得
231 232 233 |
# File 'lib/when_exe/core/extension.rb', line 231 def calendar When::Parts::Resource._instance(self, '_c:') end |
#calendar_era ⇒ When::TM::CalendarEra Also known as: to_calendar_era
core/extension
self をプレフィクス ‘_e:’ を省略した IRI とみなして When::TM::CalendarEra を取得
255 256 257 |
# File 'lib/when_exe/core/extension.rb', line 255 def calendar_era When::Parts::Resource._instance(self, '_e:') end |
#calendar_note ⇒ When::TM::CalendarNote Also known as: to_calendar_note
core/extension
self をプレフィクス ‘_c:’ を省略した IRI とみなして When::TM::CalendarNote を取得
243 244 245 |
# File 'lib/when_exe/core/extension.rb', line 243 def calendar_note When::Parts::Resource._instance(self, '_n:') end |
#encode(code) ⇒ String
encode
21 22 23 |
# File 'lib/when_exe/core/compatibility.rb', line 21 def encode(code) return Iconv.iconv(code, 'UTF-8', self)[0] end |
#calendar_era(options = {}) ⇒ Array<When::TM::CalendarEra> Also known as: to_era
core/extension
self を検索する暦年代とみなして登録された When::TM::CalendarEraを検索
297 298 299 |
# File 'lib/when_exe/core/extension.rb', line 297 def era(*args) When::TM::CalendarEra._instance(*([self] + args)) end |
#ideographic_unification(pattern = When::Parts::Locale._unification) ⇒ String
包摂リストに登録されている文字を包摂する
206 207 208 |
# File 'lib/when_exe/core/extension.rb', line 206 def ideographic_unification(pattern=When::Parts::Locale._unification) When::Parts::Locale.ideographic_unification(self, pattern) end |
#m17n ⇒ When::BasicTypes::M17n
core/extension
self をプレフィクス ‘_m:’ を省略した IRI とみなして When::BasicTypes::M17n を取得
267 268 269 |
# File 'lib/when_exe/core/extension.rb', line 267 def m17n When::Parts::Resource._instance(self, '_m:') end |
#ord ⇒ Integer
文字列の先頭文字のコードを取得する (多バイト文字非対応)
51 52 53 |
# File 'lib/when_exe/core/compatibility.rb', line 51 def ord self[0] end |
#resource(namespace = nil) ⇒ When::Parts::Resource Also known as: to_resource
core/extension
self を IRI とみなして When::Parts::Resource を取得
219 220 221 |
# File 'lib/when_exe/core/extension.rb', line 219 def resource(namespace=nil) When::Parts::Resource._instance(self, namespace) end |
#to_m17n ⇒ When::BasicTypes::M17n
core/extension
self を When::BasicTypes::M17n に変換する
182 183 184 |
# File 'lib/when_exe/core/extension.rb', line 182 def to_m17n When::BasicTypes::M17n.new(self) end |
#to_month_name ⇒ When::BasicTypes::M17n Also known as: month_name
core/extension
月名
self の最初の3文字から決定した月名を返します。 一致する月名がない場合、名前の一致するその他のM17nを探して返します。 (self が M17n なら name 自身をそのまま返します)
348 349 350 |
# File 'lib/when_exe/core/extension.rb', line 348 def to_month_name When::BasicTypes::M17n.month_name(self) end |
#to_pair ⇒ When::Coordinates::Pair Also known as: pair
self を幹と枝の要素と解釈してWhen::Coordinates::Pair を生成
277 278 279 |
# File 'lib/when_exe/core/extension.rb', line 277 def to_pair Coordinates::Pair._force_pair(self) end |
#to_r ⇒ Numeric
to_r(もどき)
文字列を numeric に変換する (できるだけ情報が落ちない型を選択)
33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/when_exe/core/compatibility.rb', line 33 def to_r case self when /\.|E/i to_f when /\// Rational Rational(*split(/\//).map {|v| v.to_i}) else to_i end end |
#to_residue ⇒ When::Coordinates::Residue Also known as: residue, day_of_week
core/extension
曜日(剰余類)
self の最初の3文字から決定した七曜(剰余類)を返します。 一致する七曜(剰余類)がない場合、名前の一致するその他の剰余類を探して返します。
331 332 333 |
# File 'lib/when_exe/core/extension.rb', line 331 def to_residue When::Coordinates::Residue.to_residue(self) end |
#translate(loc = '') ⇒ String Also known as: /
core/extension
特定 locale に対応した文字列の取得
194 195 196 197 |
# File 'lib/when_exe/core/extension.rb', line 194 def translate(loc='') return encode($1) if loc =~ /\.(.+)$/ return self end |
#when?(options = {}) ⇒ When::TM::TemporalPosition Also known as: tm_position, to_tm_position
core/extension
self をWhen.exe Standard Expression とみなして When::TM::TemporalPosition を生成
313 314 315 |
# File 'lib/when_exe/core/extension.rb', line 313 def when?(={}) When.when?(self, ) end |