Class: TelegramBot::Date

Inherits:
Object
  • Object
show all
Includes:
AutoFromMethods
Defined in:
lib/telegram_bot/date.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from AutoFromMethods

included

Constructor Details

#initialize(datetime) ⇒ Date

Returns a new instance of Date.



33
34
35
# File 'lib/telegram_bot/date.rb', line 33

def initialize(datetime)
  @datetime = datetime
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(sym, *args, &blk) ⇒ Object



37
38
39
# File 'lib/telegram_bot/date.rb', line 37

def method_missing(sym, *args, &blk)
  @datetime.send(sym, *args, &blk)
end

Instance Attribute Details

#datetimeObject

Returns the value of attribute datetime.



27
28
29
# File 'lib/telegram_bot/date.rb', line 27

def datetime
  @datetime
end

Class Method Details

.from(date) ⇒ Object



11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/telegram_bot/date.rb', line 11

def self.from(date)
  case date
  when ::DateTime, ::Date, ::Time
    new(date)
  when Integer
    new(Time.at(date).to_datetime)
  when String
    new(Datetime.parse(date))
  when TelegramBot::Date
    date
  else
    super
  end
end

.membersObject



7
8
9
# File 'lib/telegram_bot/date.rb', line 7

def self.members
  []
end

Instance Method Details

#membersObject



29
30
31
# File 'lib/telegram_bot/date.rb', line 29

def members
  self.class.members
end