Class: ProgramR::Environment
- Inherits:
-
Object
- Object
- ProgramR::Environment
show all
- Defined in:
- lib/programr/environment.rb
Constant Summary
collapse
- @@readOnlyTags =
nil
- @@history =
nil
Instance Method Summary
collapse
Constructor Details
Returns a new instance of Environment.
9
10
11
12
13
14
15
16
17
|
# File 'lib/programr/environment.rb', line 9
def initialize
return self unless(@@readOnlyTags == nil)
@@readOnlyTags = YAML::load(
File.open(
File.dirname(__FILE__) +
"/../../conf/readOnlyTags.yaml"))
@@history = History.new
srand(1)
end
|
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(methId) ⇒ Object
28
29
30
31
32
33
|
# File 'lib/programr/environment.rb', line 28
def method_missing(methId)
tag = methId.id2name
return @@history.send(tag) if(tag =~ /that$/)
return @@readOnlyTags[tag] if(@@readOnlyTags.key?(tag))
''
end
|
Instance Method Details
#female ⇒ Object
58
59
60
61
|
# File 'lib/programr/environment.rb', line 58
def female
@@readOnlyTags['gender'] = 'female'
return 'female'
end
|
#get(aTag) ⇒ Object
19
20
21
|
# File 'lib/programr/environment.rb', line 19
def get(aTag)
send(aTag)
end
|
#getRandom(anArrayofChoices) ⇒ Object
67
68
69
|
# File 'lib/programr/environment.rb', line 67
def getRandom(anArrayofChoices)
anArrayofChoices[rand(anArrayofChoices.length)]
end
|
#getStimula(anIndex) ⇒ Object
71
72
73
|
# File 'lib/programr/environment.rb', line 71
def getStimula(anIndex)
@@history.getStimula(anIndex)
end
|
#male ⇒ Object
53
54
55
56
|
# File 'lib/programr/environment.rb', line 53
def male
@@readOnlyTags['gender'] = 'male'
return 'male'
end
|
#question ⇒ Object
63
64
65
|
# File 'lib/programr/environment.rb', line 63
def question
@@readOnlyTags['question'][rand(@@readOnlyTags['question'].length)]
end
|
#set(aTag, aValue) ⇒ Object
23
24
25
26
|
# File 'lib/programr/environment.rb', line 23
def set(aTag,aValue)
@@history.updateTopic(aValue) if(aTag == 'topic')
@@readOnlyTags[aTag] = aValue
end
|
#star(anIndex) ⇒ Object
41
42
43
|
# File 'lib/programr/environment.rb', line 41
def star(anIndex)
@@history.getStar(anIndex)
end
|
#test ⇒ Object
35
36
37
38
39
|
# File 'lib/programr/environment.rb', line 35
def test
return @@readOnlyTags[tag] if(@@readOnlyTags.key?(tag))
''
end
|
#thatstar(anIndex) ⇒ Object
45
46
47
|
# File 'lib/programr/environment.rb', line 45
def thatstar(anIndex)
@@history.getThatStar(anIndex)
end
|
#topicstar(anIndex) ⇒ Object
49
50
51
|
# File 'lib/programr/environment.rb', line 49
def topicstar(anIndex)
@@history.getTopicStar(anIndex)
end
|