Class: Qippet::Boxes::CodeBox
Overview
Box for creating code
Defined Under Namespace
Classes: BareColorFormatter
Constant Summary collapse
- ALLOWED_ATTRIBUTES =
%i[source path range].freeze
- TAB_SPACE =
20
- CODE_LINE_HEIGHT =
19
- CODE_CHAR_WIDTH =
8
Constants inherited from Box
Instance Attribute Summary collapse
-
#code_content ⇒ Object
readonly
Returns the value of attribute code_content.
-
#code_lines ⇒ Object
readonly
Returns the value of attribute code_lines.
-
#formatter ⇒ Object
readonly
Returns the value of attribute formatter.
-
#show_line ⇒ Object
readonly
Returns the value of attribute show_line.
-
#tokenizer ⇒ Object
readonly
Returns the value of attribute tokenizer.
-
#writer ⇒ Object
readonly
Returns the value of attribute writer.
Attributes inherited from Box
Instance Method Summary collapse
- #add_child ⇒ Object
-
#initialize ⇒ CodeBox
constructor
A new instance of CodeBox.
- #render ⇒ Object
Methods inherited from Box
#add_attributes, #children, setup_attributes
Constructor Details
#initialize ⇒ CodeBox
Returns a new instance of CodeBox.
34 35 36 37 |
# File 'lib/qippet/boxes/code_box.rb', line 34 def initialize super @show_line = false end |
Instance Attribute Details
#code_content ⇒ Object (readonly)
Returns the value of attribute code_content.
26 27 28 |
# File 'lib/qippet/boxes/code_box.rb', line 26 def code_content @code_content end |
#code_lines ⇒ Object (readonly)
Returns the value of attribute code_lines.
26 27 28 |
# File 'lib/qippet/boxes/code_box.rb', line 26 def code_lines @code_lines end |
#formatter ⇒ Object (readonly)
Returns the value of attribute formatter.
26 27 28 |
# File 'lib/qippet/boxes/code_box.rb', line 26 def formatter @formatter end |
#show_line ⇒ Object (readonly)
Returns the value of attribute show_line.
26 27 28 |
# File 'lib/qippet/boxes/code_box.rb', line 26 def show_line @show_line end |
#tokenizer ⇒ Object (readonly)
Returns the value of attribute tokenizer.
26 27 28 |
# File 'lib/qippet/boxes/code_box.rb', line 26 def tokenizer @tokenizer end |
#writer ⇒ Object (readonly)
Returns the value of attribute writer.
26 27 28 |
# File 'lib/qippet/boxes/code_box.rb', line 26 def writer @writer end |
Instance Method Details
#add_child ⇒ Object
39 40 41 |
# File 'lib/qippet/boxes/code_box.rb', line 39 def add_child(*) throw :no_children_for_node, "Code Box cannot contain chidren" end |
#render ⇒ Object
43 44 45 46 47 48 49 50 51 52 |
# File 'lib/qippet/boxes/code_box.rb', line 43 def render fetch_code_from_source extract_line_range return nil if code_content.nil? setup_syntax_highliter setup_writer super write_code_on_image end |