Class: Literate::Programming
- Inherits:
-
Object
- Object
- Literate::Programming
- Defined in:
- lib/literate/programming.rb,
lib/literate/programming/version.rb
Constant Summary collapse
- VERSION =
"1.3.0"
Instance Attribute Summary collapse
-
#expandtab ⇒ Object
writeonly
Sets the attribute expandtab.
-
#tabstop ⇒ Object
writeonly
Sets the attribute tabstop.
Instance Method Summary collapse
- #<<(append) ⇒ Object
-
#initialize(src = "", source: nil, tabstop: 2, expandtab: true) ⇒ Programming
constructor
A new instance of Programming.
- #inspect ⇒ Object
- #to_md ⇒ Object
- #to_ruby ⇒ Object
- #to_tex ⇒ Object
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 = @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
5 6 7 |
# File 'lib/literate/programming.rb', line 5 def (value) = value end |
#tabstop=(value) ⇒ Object (writeonly)
Sets the attribute tabstop
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 |
#inspect ⇒ Object
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_md ⇒ Object
31 32 33 |
# File 'lib/literate/programming.rb', line 31 def to_md convert[:md] end |
#to_ruby ⇒ Object
27 28 29 |
# File 'lib/literate/programming.rb', line 27 def to_ruby convert[:rb] end |
#to_tex ⇒ Object
35 36 37 |
# File 'lib/literate/programming.rb', line 35 def to_tex convert[:tex] end |