I'm a complete ruby newbie and am trying to understand more of the modular scale library https://github.com/scottkellum/modular-scale
I wish to test out some of the functionality in irb and here is my result:
>> require 'modular-scale' => true >> module module >> modular-scale(2) NameError: undefined local variable or method `modular' for main:Object from (irb):2 >> modularScale(2) NoMethodError: undefined method `modularScale' for main:Object from (irb):3 >> $ratio => nil >> golden() NoMethodError: undefined method `golden' for main:Object from (irb):5
I realise that it is a compass plugin but it would be good to run some of its functions on irb. I'm more interested in the writing and testing of compass plugins than on modular scale itself. I picked the library because I thought it looked more straight forward than others.
any help would be appreciated
in https://github.com/scottkellum/modular-scale/blob/master/lib/modular-scale.rb it supplies functions that i presume are callable from irb
>> bar = Sass::Script::Number.new(12) ;; This works => 12 >> bar = Sass::Script::Functions.major_tenth() ;; I thought this might work but it doesn't NoMethodError: undefined method `major_tenth' for Sass::Script::Functions:Module from (irb):9
class SassPlay
include Sass::Script::Functions
end
SassPlay.new.double_octave
=> 4
The method modular-scale()
is a Sass function and you cannot call it from irb
. It is a style sheet function that is parsed and executed by Sass, not by irb
.
Sass is an interpreted language. It does not have a one-to-one relationship with ruby methods, hence you cannot access all of Sass's functionality directly from ruby nor irb.
You can look at the definition modular-scale()
here:
https://github.com/scottkellum/modular-scale/blob/master/stylesheets/_modular-scale.scss