Class: Html2rss::SST::Attrs

Inherits:
Data
  • Object
show all
Defined in:
lib/html2rss/sst/attrs.rb

Overview

Typed HTML attributes for an SST node. Absent fields are nil.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#class_namesObject (readonly)

Returns the value of attribute class_names

Returns:

  • (Object)

    the current value of class_names



16
17
18
# File 'lib/html2rss/sst/attrs.rb', line 16

def class_names
  @class_names
end

#datetimeObject (readonly)

Returns the value of attribute datetime

Returns:

  • (Object)

    the current value of datetime



16
17
18
# File 'lib/html2rss/sst/attrs.rb', line 16

def datetime
  @datetime
end

#hrefObject (readonly)

Returns the value of attribute href

Returns:

  • (Object)

    the current value of href



16
17
18
# File 'lib/html2rss/sst/attrs.rb', line 16

def href
  @href
end

#idObject (readonly)

Returns the value of attribute id

Returns:

  • (Object)

    the current value of id



16
17
18
# File 'lib/html2rss/sst/attrs.rb', line 16

def id
  @id
end

#itempropObject (readonly)

Returns the value of attribute itemprop

Returns:

  • (Object)

    the current value of itemprop



16
17
18
# File 'lib/html2rss/sst/attrs.rb', line 16

def itemprop
  @itemprop
end

#rawObject (readonly)

Returns the value of attribute raw

Returns:

  • (Object)

    the current value of raw



16
17
18
# File 'lib/html2rss/sst/attrs.rb', line 16

def raw
  @raw
end

#srcObject (readonly)

Returns the value of attribute src

Returns:

  • (Object)

    the current value of src



16
17
18
# File 'lib/html2rss/sst/attrs.rb', line 16

def src
  @src
end

#srcsetObject (readonly)

Returns the value of attribute srcset

Returns:

  • (Object)

    the current value of srcset



16
17
18
# File 'lib/html2rss/sst/attrs.rb', line 16

def srcset
  @srcset
end

#styleObject (readonly)

Returns the value of attribute style

Returns:

  • (Object)

    the current value of style



16
17
18
# File 'lib/html2rss/sst/attrs.rb', line 16

def style
  @style
end

#typeObject (readonly)

Returns the value of attribute type

Returns:

  • (Object)

    the current value of type



16
17
18
# File 'lib/html2rss/sst/attrs.rb', line 16

def type
  @type
end

Class Method Details

.build(href: nil, src: nil, id: nil, class_names: nil, datetime: nil, itemprop: nil, style: nil, srcset: nil, type: nil, raw: nil) ⇒ Attrs

rubocop:disable Metrics/MethodLength, Metrics/ParameterLists

Parameters:

  • href (String, nil) (defaults to: nil)
  • src (String, nil) (defaults to: nil)
  • id (String, nil) (defaults to: nil)
  • class_names (Array<String>, nil) (defaults to: nil)
  • datetime (String, nil) (defaults to: nil)
  • itemprop (String, nil) (defaults to: nil)
  • style (String, nil) (defaults to: nil)
  • srcset (String, nil) (defaults to: nil)
  • type (String, nil) (defaults to: nil)
  • raw (Hash{String => String}, nil) (defaults to: nil)

Returns:



33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# File 'lib/html2rss/sst/attrs.rb', line 33

def build(href: nil, src: nil, id: nil, class_names: nil, datetime: nil, itemprop: nil,
          style: nil, srcset: nil, type: nil, raw: nil)
  new(
    href: blank_to_nil(href),
    src: blank_to_nil(src),
    id: blank_to_nil(id),
    class_names: normalize_class_names(class_names),
    datetime: blank_to_nil(datetime),
    itemprop: blank_to_nil(itemprop),
    style: blank_to_nil(style),
    srcset: blank_to_nil(srcset),
    type: blank_to_nil(type),
    raw: normalize_raw(raw)
  )
end

.emptyAttrs

Returns:



52
# File 'lib/html2rss/sst/attrs.rb', line 52

def empty = EMPTY_ATTRS

Instance Method Details

#class_attrString

Returns:

  • (String)


82
# File 'lib/html2rss/sst/attrs.rb', line 82

def class_attr = class_names.join(' ')