Module: Less2Sass::Util

Extended by:
Util
Included in:
Util
Defined in:
lib/less2sass/util.rb

Instance Method Summary collapse

Instance Method Details

#classify(str) ⇒ String

Formats class names properly.

Examples:

formats dashed class name

"anonymous_node".classify #=> "AnonymousNode"

Returns:

  • (String)

    formatted class name



32
33
34
# File 'lib/less2sass/util.rb', line 32

def classify(str)
  str.split('_').collect!(&:capitalize).join
end

#read_stdin_as_multiline_argString

Formats a multiline console input, so it can be passed as an argument to a console application.

Returns:

  • (String)

    properly formatted multiline argument



17
18
19
20
21
22
23
24
25
# File 'lib/less2sass/util.rb', line 17

def read_stdin_as_multiline_arg
  str = ''
  puts 'Write your code below, so it can be converted for you.'
  while line = gets
    line["\n"] = "\\\n"
    str << line
  end
  str
end

#scope(file) ⇒ String

Returns a file’s path relative to the Less2Sass root directory.

Parameters:

  • file (String)

    The filename relative to the Less2Sass root

Returns:

  • (String)

    The filename relative to the the working directory



9
10
11
# File 'lib/less2sass/util.rb', line 9

def scope(file)
  File.join(Less2Sass::ROOT_DIR, file)
end