Class: LinuxFortune::FortuneSource

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

Overview

fortune source class basically a couple of strings to construct the db file path and the weight (in percentage) of the file (compared to 100%)

Instance Method Summary collapse

Constructor Details

#initialize(source = nil, path = "/usr/share/fortune", weight = nil) ⇒ FortuneSource

create a new source reference with source, path and weight



101
102
103
104
105
# File 'lib/linux_fortune.rb', line 101

def initialize(source = nil, path = "/usr/share/fortune", weight = nil )
  @source = source
  @path = path
  @weight = weight
end

Instance Method Details

#fortuneObject

gets a fortune message from this source



137
138
139
# File 'lib/linux_fortune.rb', line 137

def fortune
  LinuxFortune.generate([self.fullpath])
end

#fullpathObject

gets full path to the source



132
133
134
# File 'lib/linux_fortune.rb', line 132

def fullpath
  File.join(@path, @source)
end

#pathObject

gets the source path (directory with source)



113
114
115
# File 'lib/linux_fortune.rb', line 113

def path
  @path
end

#path=(srcpath) ⇒ Object

sets the fortune source path



108
109
110
# File 'lib/linux_fortune.rb', line 108

def path=(srcpath)
  @path = srcpath
end

#sourceObject

gets source file name



123
124
125
# File 'lib/linux_fortune.rb', line 123

def source
  @source
end

#source=(src) ⇒ Object

sets the source file name (file in FortuneSource.path)



118
119
120
# File 'lib/linux_fortune.rb', line 118

def source=(src)
  @source = src
end

#weightObject



127
128
129
# File 'lib/linux_fortune.rb', line 127

def weight
  @weight
end