Class: Rabbit::Source::Memory

Inherits:
Object
  • Object
show all
Includes:
Base
Defined in:
lib/rabbit/source/memory.rb

Instance Attribute Summary collapse

Attributes included from Base

#base, #encoding, #force_modified, #tmp_base

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Base

append_features, #full_path, #modified?, #old?, #open_full_path, #read, #tmp_dir_name

Constructor Details

#initialize(encoding, logger, name = nil) ⇒ Memory

Returns a new instance of Memory.


14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/rabbit/source/memory.rb', line 14

def initialize(encoding, logger, name=nil)
  super(encoding, logger)
  if name
    file_source = File.new(encoding, logger, name)
    @original_source = file_source.read
    set_base(file_source.base)
    @extension = extract_extension(name)
  else
    @original_source = ""
    @extension = nil
  end
  reset
end

Instance Attribute Details

#extensionObject

Returns the value of attribute extension.


12
13
14
# File 'lib/rabbit/source/memory.rb', line 12

def extension
  @extension
end

Class Method Details

.initial_args_descriptionObject


8
9
10
# File 'lib/rabbit/source/memory.rb', line 8

def self.initial_args_description
  N_("[FILENAME_OR_NOT]")
end

Instance Method Details

#_readObject


32
33
34
# File 'lib/rabbit/source/memory.rb', line 32

def _read
  @current_source
end

#need_read?Boolean

Returns:

  • (Boolean)

36
37
38
# File 'lib/rabbit/source/memory.rb', line 36

def need_read?
  super or @current_source != @source
end

#resetObject


40
41
42
# File 'lib/rabbit/source/memory.rb', line 40

def reset
  @current_source = @original_source.dup
end

#source=(new_source) ⇒ Object


28
29
30
# File 'lib/rabbit/source/memory.rb', line 28

def source=(new_source)
  @current_source = new_source
end