Class: Literate::Programming

Inherits:
Object
  • Object
show all
Defined in:
lib/literate/programming.rb,
lib/literate/programming/version.rb

Constant Summary collapse

VERSION =
"1.3.0"

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(src = "", source: nil, tabstop: 2, expandtab: true) ⇒ Programming

Returns a new instance of Programming.



7
8
9
10
11
12
13
14
15
16
17
# File 'lib/literate/programming.rb', line 7

def initialize(src = "", source: nil, tabstop: 2, expandtab: true)
  @source = source || src
  @tabstop = tabstop
  @expandtab = expandtab
  @eval_context = BasicObject.new
  @eval_context.instance_eval "    def gensym\n      return (0 .. 20).collect { ('a' .. 'z').to_a[::Random.rand(26)] }.join\n    end\n  EOC\nend\n"

Instance Attribute Details

#expandtab=(value) ⇒ Object (writeonly)

Sets the attribute expandtab

Parameters:

  • value

    the value to set the attribute expandtab to.



5
6
7
# File 'lib/literate/programming.rb', line 5

def expandtab=(value)
  @expandtab = value
end

#tabstop=(value) ⇒ Object (writeonly)

Sets the attribute tabstop

Parameters:

  • value

    the value to set the attribute tabstop to.



5
6
7
# File 'lib/literate/programming.rb', line 5

def tabstop=(value)
  @tabstop = value
end

Instance Method Details

#<<(append) ⇒ Object



23
24
25
# File 'lib/literate/programming.rb', line 23

def <<(append)
  @source << append
end

#inspectObject



19
20
21
# File 'lib/literate/programming.rb', line 19

def inspect
  return "#<Literate::Programming:0x#{object_id.to_s(16)} tabstop=#{@tabstop} expandtab=#{@expandtab}>"
end

#to_mdObject



31
32
33
# File 'lib/literate/programming.rb', line 31

def to_md
  convert[:md]
end

#to_rubyObject



27
28
29
# File 'lib/literate/programming.rb', line 27

def to_ruby
  convert[:rb]
end

#to_texObject



35
36
37
# File 'lib/literate/programming.rb', line 35

def to_tex
  convert[:tex]
end