Class: LinuxFortune::FortuneSource
- Inherits:
-
Object
- Object
- LinuxFortune::FortuneSource
- 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
-
#fortune ⇒ Object
gets a fortune message from this source.
-
#fullpath ⇒ Object
gets full path to the source.
-
#initialize(source = nil, path = "/usr/share/fortune", weight = nil) ⇒ FortuneSource
constructor
create a new source reference with source, path and weight.
-
#path ⇒ Object
gets the source path (directory with source).
-
#path=(srcpath) ⇒ Object
sets the fortune source path.
-
#source ⇒ Object
gets source file name.
-
#source=(src) ⇒ Object
sets the source file name (file in FortuneSource.path).
- #weight ⇒ Object
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
#fortune ⇒ Object
gets a fortune message from this source
137 138 139 |
# File 'lib/linux_fortune.rb', line 137 def fortune LinuxFortune.generate([self.fullpath]) end |
#fullpath ⇒ Object
gets full path to the source
132 133 134 |
# File 'lib/linux_fortune.rb', line 132 def fullpath File.join(@path, @source) end |
#path ⇒ Object
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 |
#source ⇒ Object
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 |
#weight ⇒ Object
127 128 129 |
# File 'lib/linux_fortune.rb', line 127 def weight @weight end |