lib/when_exe/calendarnote.rb in when_exe-0.4.4 vs lib/when_exe/calendarnote.rb in when_exe-0.4.5
- old
+ new
@@ -33,23 +33,13 @@
@_pool[key]
end
end
#
- # 暦注要素のひな形クラス
+ # 暦注要素であることを示す
#
- # @private
- class NoteElement < When::BasicTypes::Object
- #
- # _m17n_form のための要素生成
- #
- # @param [Hash] options 下記のとおり
- # @option options [Symbol] :method :to_m17n なら label を返す、その他は When::Parts::Resource#to_h 参照
- #
- def _to_hash_value(options={})
- options[:method] == :to_m17n ? label : super
- end
+ module NoteElement
end
#
# 暦注検索結果を保存するコンテナ
#
@@ -439,11 +429,11 @@
# return Array of Hash
focused_notes.map {|note|
nobj = note_objects[note]
case notes[note]
when nil, false ; {}
- when Hash ; {:note=>nobj.label}.merge(notes[note])
+ when Hash ; {:note=>nobj}.merge(notes[note])
else
if nobj.respond_to?(:to_note_hash)
nobj.to_note_hash(notes[note], dates)
else
{:note=>nobj.kind_of?(String) ? nobj : nobj.label, :value=>notes[note]}
@@ -474,10 +464,11 @@
case arg
when String
arg, method = $1, $2 if (arg =~ /\A(.+)#([_A-Z0-9]+)\z/i)
obj = When.Resource(arg, prefix)
obj = obj.copy(method) if method
+ obj.extend NoteElement
obj
when Array
_to_iri(arg, prefix)
else
arg
@@ -604,9 +595,23 @@
root = _elements[index-1][note]
parent, leaf = root.iri.split('/Notes') if root.kind_of?(When::Parts::Resource)
parent = When.Resource(parent) if leaf
return parent.send(method, dates, *parameter) if parent.respond_to?(method)
root.send(When::Coordinates::PRECISION_NAME[index].downcase, dates)
+ end
+
+ #
+ # イベントの標準的な間隔を返す
+ #
+ # @param [String] parameter 座標の分子と分母("#{ num }/#{ den }" の形式)
+ #
+ # @return [When::TM::IntervalLength]
+ #
+ # @private
+ def event_delta(parameter=nil)
+ return @delta unless parameter
+ num, den = parameter.kind_of?(String) ? parameter.split(/\//, 2) : parameter
+ When::TM::IntervalLength.new([(den || @den).to_f,1].max*0.9, 'day')
end
#
# イベントを取得する Enumerator
#