Class: HamdownCore::Ast::Element

Inherits:
Struct
  • Object
show all
Includes:
HasChildren
Defined in:
lib/hamdown_core/ast.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from HasChildren

#<<

Constructor Details

#initializeElement

Returns a new instance of Element.



51
52
53
54
55
56
57
58
# File 'lib/hamdown_core/ast.rb', line 51

def initialize(*)
  super
  self.static_class ||= ''
  self.static_id ||= ''
  self.self_closing ||= false
  self.nuke_inner_whitespace ||= false
  self.nuke_outer_whitespace ||= false
end

Instance Attribute Details

#childrenObject

Returns the value of attribute children

Returns:

  • (Object)

    the current value of children



34
35
36
# File 'lib/hamdown_core/ast.rb', line 34

def children
  @children
end

#filenameObject

Returns the value of attribute filename

Returns:

  • (Object)

    the current value of filename



34
35
36
# File 'lib/hamdown_core/ast.rb', line 34

def filename
  @filename
end

#linenoObject

Returns the value of attribute lineno

Returns:

  • (Object)

    the current value of lineno



34
35
36
# File 'lib/hamdown_core/ast.rb', line 34

def lineno
  @lineno
end

#new_attributesObject

Returns the value of attribute new_attributes

Returns:

  • (Object)

    the current value of new_attributes



34
35
36
# File 'lib/hamdown_core/ast.rb', line 34

def new_attributes
  @new_attributes
end

#nuke_inner_whitespaceObject

Returns the value of attribute nuke_inner_whitespace

Returns:

  • (Object)

    the current value of nuke_inner_whitespace



34
35
36
# File 'lib/hamdown_core/ast.rb', line 34

def nuke_inner_whitespace
  @nuke_inner_whitespace
end

#nuke_outer_whitespaceObject

Returns the value of attribute nuke_outer_whitespace

Returns:

  • (Object)

    the current value of nuke_outer_whitespace



34
35
36
# File 'lib/hamdown_core/ast.rb', line 34

def nuke_outer_whitespace
  @nuke_outer_whitespace
end

#object_refObject

Returns the value of attribute object_ref

Returns:

  • (Object)

    the current value of object_ref



34
35
36
# File 'lib/hamdown_core/ast.rb', line 34

def object_ref
  @object_ref
end

#old_attributesObject

Returns the value of attribute old_attributes

Returns:

  • (Object)

    the current value of old_attributes



34
35
36
# File 'lib/hamdown_core/ast.rb', line 34

def old_attributes
  @old_attributes
end

#oneline_childObject

Returns the value of attribute oneline_child

Returns:

  • (Object)

    the current value of oneline_child



34
35
36
# File 'lib/hamdown_core/ast.rb', line 34

def oneline_child
  @oneline_child
end

#self_closingObject

Returns the value of attribute self_closing

Returns:

  • (Object)

    the current value of self_closing



34
35
36
# File 'lib/hamdown_core/ast.rb', line 34

def self_closing
  @self_closing
end

#static_classObject

Returns the value of attribute static_class

Returns:

  • (Object)

    the current value of static_class



34
35
36
# File 'lib/hamdown_core/ast.rb', line 34

def static_class
  @static_class
end

#static_idObject

Returns the value of attribute static_id

Returns:

  • (Object)

    the current value of static_id



34
35
36
# File 'lib/hamdown_core/ast.rb', line 34

def static_id
  @static_id
end

#tag_nameObject

Returns the value of attribute tag_name

Returns:

  • (Object)

    the current value of tag_name



34
35
36
# File 'lib/hamdown_core/ast.rb', line 34

def tag_name
  @tag_name
end

Instance Method Details

#attributesObject

XXX: For compatibility



68
69
70
71
72
73
74
75
76
77
78
# File 'lib/hamdown_core/ast.rb', line 68

def attributes
  attrs = old_attributes || ''
  if new_attributes
    if attrs.empty?
      attrs = new_attributes
    else
      attrs += ", #{new_attributes}"
    end
  end
  attrs
end

#to_hObject



60
61
62
63
64
65
# File 'lib/hamdown_core/ast.rb', line 60

def to_h
  super.merge(
    type: 'element',
    oneline_child: oneline_child && oneline_child.to_h,
  )
end