Class: WebifyRuby::Html
- Inherits:
-
Object
- Object
- WebifyRuby::Html
- Defined in:
- lib/webify_ruby/html.rb
Overview
Public: Html class of the module which is to generate code, and write to the specified directory’s .html file.
Instance Attribute Summary collapse
-
#css_file ⇒ Object
readonly
Public: Returns the String file for created css stylesheet.
-
#font_name ⇒ Object
readonly
Internal: Returns the String font name that was converted.
-
#html_dir ⇒ Object
readonly
Internal: Returns the String name of the directory where .html file will exist.
-
#html_file ⇒ Object
readonly
Internal: Returns the String directory path where a .html.
-
#output ⇒ Object
readonly
Internal: Returns the Fixnum length of a file.
-
#result ⇒ Object
readonly
Internal: Returns the String representation of HTML file.
Instance Method Summary collapse
-
#initialize(css_file, html_dir) ⇒ Html
constructor
Public: Initialize a HTML generation.
-
#write ⇒ Object
Internal: (Re-)Create a HTML file and write code there.
Constructor Details
#initialize(css_file, html_dir) ⇒ Html
Public: Initialize a HTML generation.
css_file - A String filepath to the generated CSS. html_dir - A String path to the directory where file will be created.
Returns the String HTML document code.
161 162 163 164 165 166 167 168 |
# File 'lib/webify_ruby/html.rb', line 161 def initialize(css_file, html_dir) @css_file = css_file @html_dir = html_dir @font_name = File.basename(@css_file, ".*") make_html write end |
Instance Attribute Details
#css_file ⇒ Object (readonly)
Public: Returns the String file for created css stylesheet.
143 144 145 |
# File 'lib/webify_ruby/html.rb', line 143 def css_file @css_file end |
#font_name ⇒ Object (readonly)
Internal: Returns the String font name that was converted.
147 148 149 |
# File 'lib/webify_ruby/html.rb', line 147 def font_name @font_name end |
#html_dir ⇒ Object (readonly)
Internal: Returns the String name of the directory where .html file will exist.
145 146 147 |
# File 'lib/webify_ruby/html.rb', line 145 def html_dir @html_dir end |
#html_file ⇒ Object (readonly)
Internal: Returns the String directory path where a .html.
149 150 151 |
# File 'lib/webify_ruby/html.rb', line 149 def html_file @html_file end |
#output ⇒ Object (readonly)
Internal: Returns the Fixnum length of a file.
151 152 153 |
# File 'lib/webify_ruby/html.rb', line 151 def output @output end |
#result ⇒ Object (readonly)
Internal: Returns the String representation of HTML file.
153 154 155 |
# File 'lib/webify_ruby/html.rb', line 153 def result @result end |
Instance Method Details
#write ⇒ Object
Internal: (Re-)Create a HTML file and write code there.
Returns the HTML filepath just created.
173 174 175 176 177 178 179 180 |
# File 'lib/webify_ruby/html.rb', line 173 def write @dir = FileUtils.mkdir_p @html_dir unless File.directory? @html_dir @html_file = File.join(@html_dir, @font_name + '.html') File.delete(@html_file) if File.exist?(@html_file) @output = File.open(@html_file, 'w') { |file| file.write(@result) } @html_file end |