Class: Zakuro::Operation::Number
- Inherits:
-
Object
- Object
- Zakuro::Operation::Number
- Defined in:
- lib/zakuro/operation/month/type.rb
Overview
Number 月
Instance Attribute Summary collapse
-
#dest ⇒ Integer
readonly
移動先.
-
#src ⇒ Integer
readonly
移動元.
Instance Method Summary collapse
-
#change_year? ⇒ True, False
年変化するか.
-
#initialize(src: -1,, dest: -1)) ⇒ Number
constructor
初期化.
-
#interval ⇒ Integer
差分の間隔.
-
#invalid? ⇒ True, False
無効か.
-
#last_year? ⇒ True, False
昨年の月か.
-
#next_year? ⇒ True, False
来年の月か.
-
#valid? ⇒ True, False
無効か.
Constructor Details
#initialize(src: -1,, dest: -1)) ⇒ Number
初期化
353 354 355 356 |
# File 'lib/zakuro/operation/month/type.rb', line 353 def initialize(src: -1, dest: -1) @src = src @dest = dest end |
Instance Attribute Details
#dest ⇒ Integer (readonly)
Returns 移動先.
345 346 347 |
# File 'lib/zakuro/operation/month/type.rb', line 345 def dest @dest end |
#src ⇒ Integer (readonly)
Returns 移動元.
343 344 345 |
# File 'lib/zakuro/operation/month/type.rb', line 343 def src @src end |
Instance Method Details
#change_year? ⇒ True, False
年変化するか
393 394 395 396 397 398 399 400 |
# File 'lib/zakuro/operation/month/type.rb', line 393 def change_year? return false unless valid? # 1年分の変化(12ヶ月以上)なしと見なす return false if interval.abs < 11 true end |
#interval ⇒ Integer
差分の間隔
383 384 385 |
# File 'lib/zakuro/operation/month/type.rb', line 383 def interval src - dest end |
#invalid? ⇒ True, False
無効か
364 365 366 |
# File 'lib/zakuro/operation/month/type.rb', line 364 def invalid? src == -1 || dest == -1 end |
#last_year? ⇒ True, False
昨年の月か
408 409 410 411 412 |
# File 'lib/zakuro/operation/month/type.rb', line 408 def last_year? return false unless change_year? interval.negative? end |
#next_year? ⇒ True, False
来年の月か
420 421 422 423 424 |
# File 'lib/zakuro/operation/month/type.rb', line 420 def next_year? return false unless change_year? interval.positive? end |
#valid? ⇒ True, False
無効か
374 375 376 |
# File 'lib/zakuro/operation/month/type.rb', line 374 def valid? !invalid? end |