Class: SuriLang::Greeter

Inherits:
Object
  • Object
show all
Defined in:
lib/suri_lang/greeter.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(message, source, season) ⇒ Greeter

Returns a new instance of Greeter.



9
10
11
12
13
# File 'lib/suri_lang/greeter.rb', line 9

def initialize(message, source, season)
  @message = message
  @source = source
  @season = season
end

Instance Attribute Details

#messageObject (readonly)

Returns the value of attribute message.



5
6
7
# File 'lib/suri_lang/greeter.rb', line 5

def message
  @message
end

#seasonObject (readonly)

Returns the value of attribute season.



7
8
9
# File 'lib/suri_lang/greeter.rb', line 7

def season
  @season
end

#sourceObject (readonly)

Returns the value of attribute source.



6
7
8
# File 'lib/suri_lang/greeter.rb', line 6

def source
  @source
end

Class Method Details

.greetObject



20
21
22
# File 'lib/suri_lang/greeter.rb', line 20

def self.greet
  self.greeting_list.sample['message']
end

.greeting_listObject



24
25
26
# File 'lib/suri_lang/greeter.rb', line 24

def self.greeting_list
  YAML.load_file(File.expand_path("../greeter/greetings.yml", __FILE__))
end

.random_buildObject



15
16
17
18
# File 'lib/suri_lang/greeter.rb', line 15

def self.random_build
  greeting = self.greeting_list.sample
  self.new(greeting['message'], greeting['source'], greeting['season'])
end