Class: Less::Loader::Buffer

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

Overview

:nodoc:

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(data, encoding = nil) ⇒ Buffer

Returns a new instance of Buffer.



108
109
110
111
112
113
# File 'lib/less/loader.rb', line 108

def initialize(data, encoding = nil)
  unless data.is_a? String
    data = data.to_ruby
  end
  @data = data
end

Instance Attribute Details

#dataObject

Returns the value of attribute data.



106
107
108
# File 'lib/less/loader.rb', line 106

def data
  @data
end

Instance Method Details

#lengthObject



115
116
117
# File 'lib/less/loader.rb', line 115

def length
  @data.length
end

#toString(encoding = nil, begPos = 0, endPos = length) ⇒ Object



119
120
121
122
123
124
125
126
127
# File 'lib/less/loader.rb', line 119

def toString(encoding = nil, begPos = 0, endPos = length)
  data = @data[ begPos..endPos ]
  if encoding == 'base64'
    data = Base64.encode64(data)
    data.delete!("\n"); data
  else # encoding == 'binary'
    data
  end
end