Class: HTML::Tag

Inherits:
Struct show all
Includes:
StripTags
Defined in:
lib/langhelp/langhelp-base.rb

Constant Summary

Constants included from StripTags

StripTags::ALT, StripTags::NQ, StripTags::Q

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from StripTags

#html2txt!

Instance Attribute Details

#contentObject

Returns the value of attribute content

Returns:

  • (Object)

    the current value of content



432
433
434
# File 'lib/langhelp/langhelp-base.rb', line 432

def content
  @content
end

#elementObject

Returns the value of attribute element

Returns:

  • (Object)

    the current value of element



432
433
434
# File 'lib/langhelp/langhelp-base.rb', line 432

def element
  @element
end

#filenameObject

Returns the value of attribute filename

Returns:

  • (Object)

    the current value of filename



432
433
434
# File 'lib/langhelp/langhelp-base.rb', line 432

def filename
  @filename
end

#noObject

Returns the value of attribute no

Returns:

  • (Object)

    the current value of no



432
433
434
# File 'lib/langhelp/langhelp-base.rb', line 432

def no
  @no
end

Instance Method Details

#labelObject



441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
# File 'lib/langhelp/langhelp-base.rb', line 441

def label
  self.content = content.dup
  html2txt! content
  content.gsub! /\r?\n/, ' '
  if element =~ /^<h([1-6])/i
    header = "  " + "="*$1.to_i + " "
  elsif element =~  /^<dt/i
    header = "  : "
  elsif element =~ /^<title/i
    header = "Title: "
  else
    raise "cannot happen"
  end
  header + content
end

#urlObject



433
434
435
436
437
# File 'lib/langhelp/langhelp-base.rb', line 433

def url
  url = "file://" + File.expand_path(filename)
  url << "##{no}" if no
  url
end