Class: Paru::PandocFilter::ColSpec
- Inherits:
-
Object
- Object
- Paru::PandocFilter::ColSpec
- Defined in:
- lib/paru/filter/col_spec.rb
Overview
ColSpec represents a colspec definition for a table column. It contains an alignment and the column's width.
Instance Attribute Summary collapse
Instance Method Summary collapse
-
#initialize(contents = DEFAULT_COLSPEC) ⇒ ColSpec
constructor
Create a new ColSpec object.
-
#to_ast ⇒ Array
Convert this attributes object to an AST representation.
Constructor Details
Instance Attribute Details
#alignment ⇒ String
42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 |
# File 'lib/paru/filter/col_spec.rb', line 42 class ColSpec attr_reader :alignment, :width # Create a new ColSpec object # # @param contents [Array = DEFAULT_COLSPEC] the attributes as a pair of [alignment, width] def initialize(contents = DEFAULT_COLSPEC) @alignment = Value.new contents[0] @width = Value.new contents[1] end # Set the width # # @param [String|Integer|Float] new_width the new width. If it is # "ColWidthDefault", it uses the default value. def width=(new_width) if new_width == "ColWidthDefault" then @width = Value.new({"t" => new_width}) else @width = Value.new({"t" => "ColWidth", "c" => new_width}) end end # Set the alignment # # @param [String] new_alignment the new alignment. def alignment=(new_alignment) @alignment.value = new_alignment end # Convert this attributes object to an AST representation # # @return [Array] Array containing id, class name list, and # key-value pair list def to_ast [ @alignment.to_ast, @width.to_ast ] end end |
#width ⇒ Double|COL_WIDTH_DEFAULT
42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 |
# File 'lib/paru/filter/col_spec.rb', line 42 class ColSpec attr_reader :alignment, :width # Create a new ColSpec object # # @param contents [Array = DEFAULT_COLSPEC] the attributes as a pair of [alignment, width] def initialize(contents = DEFAULT_COLSPEC) @alignment = Value.new contents[0] @width = Value.new contents[1] end # Set the width # # @param [String|Integer|Float] new_width the new width. If it is # "ColWidthDefault", it uses the default value. def width=(new_width) if new_width == "ColWidthDefault" then @width = Value.new({"t" => new_width}) else @width = Value.new({"t" => "ColWidth", "c" => new_width}) end end # Set the alignment # # @param [String] new_alignment the new alignment. def alignment=(new_alignment) @alignment.value = new_alignment end # Convert this attributes object to an AST representation # # @return [Array] Array containing id, class name list, and # key-value pair list def to_ast [ @alignment.to_ast, @width.to_ast ] end end |
Instance Method Details
#to_ast ⇒ Array
Convert this attributes object to an AST representation
76 77 78 79 80 81 |
# File 'lib/paru/filter/col_spec.rb', line 76 def to_ast [ @alignment.to_ast, @width.to_ast ] end |