Class: Redcarpeter::Base
- Inherits:
-
Object
- Object
- Redcarpeter::Base
- Defined in:
- lib/redcarpeter.rb
Instance Attribute Summary collapse
-
#args ⇒ Object
readonly
Returns the value of attribute args.
-
#extension ⇒ Object
readonly
Returns the value of attribute extension.
-
#filename ⇒ Object
readonly
Returns the value of attribute filename.
-
#input ⇒ Object
readonly
Returns the value of attribute input.
Class Method Summary collapse
Instance Method Summary collapse
- #compile! ⇒ Object
-
#initialize(*args) ⇒ Base
constructor
A new instance of Base.
- #markdown ⇒ Object
Constructor Details
#initialize(*args) ⇒ Base
Returns a new instance of Base.
18 19 20 21 22 23 24 25 |
# File 'lib/redcarpeter.rb', line 18 def initialize *args @args = args.flatten @input = @args.first @extension = File.extname(@input) @filename = File.basename(@input, @extension) end |
Instance Attribute Details
#args ⇒ Object (readonly)
Returns the value of attribute args.
16 17 18 |
# File 'lib/redcarpeter.rb', line 16 def args @args end |
#extension ⇒ Object (readonly)
Returns the value of attribute extension.
16 17 18 |
# File 'lib/redcarpeter.rb', line 16 def extension @extension end |
#filename ⇒ Object (readonly)
Returns the value of attribute filename.
16 17 18 |
# File 'lib/redcarpeter.rb', line 16 def filename @filename end |
#input ⇒ Object (readonly)
Returns the value of attribute input.
16 17 18 |
# File 'lib/redcarpeter.rb', line 16 def input @input end |
Class Method Details
.compile(*args) ⇒ Object
28 29 30 |
# File 'lib/redcarpeter.rb', line 28 def compile *args new(args).compile! end |
Instance Method Details
#compile! ⇒ Object
37 38 39 40 41 |
# File 'lib/redcarpeter.rb', line 37 def compile! File.open("#{filename}.html", 'w') do |file| file.write(markdown.to_html) end end |
#markdown ⇒ Object
33 34 35 |
# File 'lib/redcarpeter.rb', line 33 def markdown @markdown ||= Redcarpet.new(File.read(@input)) end |