Class: CRFPP::Model
Instance Attribute Summary collapse
-
#data ⇒ Object
readonly
Returns the value of attribute data.
Attributes included from Filelike
Instance Method Summary collapse
- #data? ⇒ Boolean
-
#initialize(path = nil) ⇒ Model
constructor
A new instance of Model.
- #open ⇒ Object
- #save ⇒ Object
- #save_to(file) ⇒ Object
Methods included from Filelike
Constructor Details
#initialize(path = nil) ⇒ Model
Returns a new instance of Model.
8 9 10 |
# File 'lib/crfpp/model.rb', line 8 def initialize(path = nil) @data, @path = '', path end |
Instance Attribute Details
#data ⇒ Object (readonly)
Returns the value of attribute data.
6 7 8 |
# File 'lib/crfpp/model.rb', line 6 def data @data end |
Instance Method Details
#data? ⇒ Boolean
25 26 27 |
# File 'lib/crfpp/model.rb', line 25 def data? data && !data.empty? end |
#open ⇒ Object
12 13 14 15 |
# File 'lib/crfpp/model.rb', line 12 def open @data = read self end |
#save ⇒ Object
17 18 19 |
# File 'lib/crfpp/model.rb', line 17 def save save_to(path) end |
#save_to(file) ⇒ Object
21 22 23 |
# File 'lib/crfpp/model.rb', line 21 def save_to(file) write(file, data? ? data : read) end |