Class: MasterView::MIO::StringMIO
- Includes:
- MasterViewIOIdenticalMixin
- Defined in:
- lib/masterview/io.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#exist ⇒ Object
Returns the value of attribute exist.
-
#mtime ⇒ Object
readonly
Returns the value of attribute mtime.
Attributes inherited from MIOBase
Instance Method Summary collapse
- #exist? ⇒ Boolean
-
#initialize(path, string_hash, mtime = Time.new) ⇒ StringMIO
constructor
A new instance of StringMIO.
- #read(options = {}) ⇒ Object
-
#remove ⇒ Object
remove - delete hash entry.
- #write(content = nil, options = {}, &block) ⇒ Object
Methods included from MasterViewIOIdenticalMixin
Methods inherited from MIOBase
Constructor Details
#initialize(path, string_hash, mtime = Time.new) ⇒ StringMIO
Returns a new instance of StringMIO.
274 275 276 277 278 |
# File 'lib/masterview/io.rb', line 274 def initialize(path, string_hash, mtime = Time.new) super(path) @string_hash = string_hash @mtime = mtime end |
Instance Attribute Details
#exist ⇒ Object
Returns the value of attribute exist.
271 272 273 |
# File 'lib/masterview/io.rb', line 271 def exist @exist end |
#mtime ⇒ Object (readonly)
Returns the value of attribute mtime.
272 273 274 |
# File 'lib/masterview/io.rb', line 272 def mtime @mtime end |
Instance Method Details
#exist? ⇒ Boolean
300 301 302 |
# File 'lib/masterview/io.rb', line 300 def exist? @string_hash.has_key?(self.pathname.to_s) end |
#read(options = {}) ⇒ Object
280 281 282 |
# File 'lib/masterview/io.rb', line 280 def read( = {}) @string_hash[self.pathname.to_s] end |
#remove ⇒ Object
remove - delete hash entry
305 306 307 |
# File 'lib/masterview/io.rb', line 305 def remove @string_hash.delete(self.pathname.to_s) end |
#write(content = nil, options = {}, &block) ⇒ Object
284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 |
# File 'lib/masterview/io.rb', line 284 def write(content = nil, = {}, &block) written = false if block_given? sio = ::StringIO.new yield sio content = sio.string end if [:force] || !self.identical?(content) @string_hash[self.pathname.to_s] = content @mtime = Time.now written = true end written end |