Class: Fortune::Event

Inherits:
Object
  • Object
show all
Defined in:
lib/fortune/event.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(h = {}) ⇒ Event

Returns a new instance of Event.



5
6
7
8
# File 'lib/fortune/event.rb', line 5

def initialize(h = {})
  @has_come = false
  [:name, :n, :m].each{|k| instance_variable_set("@#{k}", h[k])}
end

Instance Attribute Details

#has_comeObject

Returns the value of attribute has_come.



4
5
6
# File 'lib/fortune/event.rb', line 4

def has_come
  @has_come
end

#mObject

Returns the value of attribute m.



4
5
6
# File 'lib/fortune/event.rb', line 4

def m
  @m
end

#nObject

Returns the value of attribute n.



4
5
6
# File 'lib/fortune/event.rb', line 4

def n
  @n
end

#nameObject

Returns the value of attribute name.



4
5
6
# File 'lib/fortune/event.rb', line 4

def name
  @name
end

Class Method Details

.list(h = {}) ⇒ Object



22
23
24
# File 'lib/fortune/event.rb', line 22

def self.list(h = {})
  EventList.new(h).calc
end

.select(h = {}) ⇒ Object



25
26
27
# File 'lib/fortune/event.rb', line 25

def self.select(h = {})
  Event.list(h).active.name
end

Instance Method Details

#has_come?Boolean

Returns:

  • (Boolean)


16
17
18
# File 'lib/fortune/event.rb', line 16

def has_come?
  @has_come
end

#p(h = {}) ⇒ Object



9
10
11
# File 'lib/fortune/event.rb', line 9

def p(h = {})
  P.new(:m => self.m, :n => h[:n] || self.n).value
end

#set_comeObject



19
20
21
# File 'lib/fortune/event.rb', line 19

def set_come
  @has_come = true
end

#try(h = {}) ⇒ Object



12
13
14
15
# File 'lib/fortune/event.rb', line 12

def try(h = {})
  @has_come = P.is(self.m, h[:n] || self.n)
  self
end