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 を取得.
-
#clock ⇒ When::Parts::Timezone::Base
(also: #to_clock)
self を時間帯文字列とみなして When::Parts::Timezone::Base を取得.
-
#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 を生成し“^”演算を実行
404 405 406 |
# File 'lib/when_exe/core/extension.rb', line 404 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 を取得
263 264 265 |
# File 'lib/when_exe/core/extension.rb', line 263 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 を取得
299 300 301 |
# File 'lib/when_exe/core/extension.rb', line 299 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 を取得
287 288 289 |
# File 'lib/when_exe/core/extension.rb', line 287 def calendar_note When::Parts::Resource._instance(self, '_n:') end |
#clock ⇒ When::Parts::Timezone::Base Also known as: to_clock
core/extension
self を時間帯文字列とみなして When::Parts::Timezone::Base を取得
275 276 277 |
# File 'lib/when_exe/core/extension.rb', line 275 def clock When.Clock(self) 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を検索
341 342 343 |
# File 'lib/when_exe/core/extension.rb', line 341 def era(*args) When::TM::CalendarEra._instance(*([self] + args)) end |
#ideographic_unification(pattern = When::Parts::Locale._unification) ⇒ String
包摂リストに登録されている文字を包摂する
238 239 240 |
# File 'lib/when_exe/core/extension.rb', line 238 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 を取得
311 312 313 |
# File 'lib/when_exe/core/extension.rb', line 311 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 を取得
251 252 253 |
# File 'lib/when_exe/core/extension.rb', line 251 def resource(namespace=nil) When::Parts::Resource._instance(self, namespace) end |
#to_m17n ⇒ When::BasicTypes::M17n
core/extension
self を When::BasicTypes::M17n に変換する
214 215 216 |
# File 'lib/when_exe/core/extension.rb', line 214 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 自身をそのまま返します)
392 393 394 |
# File 'lib/when_exe/core/extension.rb', line 392 def to_month_name When::BasicTypes::M17n.month_name(self) end |
#to_pair ⇒ When::Coordinates::Pair Also known as: pair
self を幹と枝の要素と解釈してWhen::Coordinates::Pair を生成
321 322 323 |
# File 'lib/when_exe/core/extension.rb', line 321 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.to_r 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文字から決定した七曜(剰余類)を返します。 一致する七曜(剰余類)がない場合、名前の一致するその他の剰余類を探して返します。
375 376 377 |
# File 'lib/when_exe/core/extension.rb', line 375 def to_residue When::Coordinates::Residue.to_residue(self) end |
#translate(loc = '') ⇒ String Also known as: /
core/extension
特定 locale に対応した文字列の取得
226 227 228 229 |
# File 'lib/when_exe/core/extension.rb', line 226 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 を生成
357 358 359 |
# File 'lib/when_exe/core/extension.rb', line 357 def when?(={}) When.when?(self, ) end |