Class: MdnQuery::Document
- Inherits:
-
Object
- Object
- MdnQuery::Document
- Defined in:
- lib/mdn_query/document.rb
Overview
A document of an entry of the Mozilla Developer Network documentation.
Instance Attribute Summary collapse
-
#section ⇒ MdnQuery::Section
readonly
The top level section.
- #title ⇒ String readonly
- #url ⇒ String readonly
Instance Method Summary collapse
-
#initialize(title, url = nil) ⇒ MdnQuery::Document
constructor
Creates a new document with an initial top level section.
-
#open ⇒ void
Opens the document in the default web browser if a URL has been specified.
-
#to_s ⇒ String
(also: #to_md)
Returns the string representation of the document.
Constructor Details
#initialize(title, url = nil) ⇒ MdnQuery::Document
Creates a new document with an initial top level section.
15 16 17 18 19 |
# File 'lib/mdn_query/document.rb', line 15 def initialize(title, url = nil) @title = title @url = url @section = MdnQuery::Section.new(title) end |
Instance Attribute Details
#section ⇒ MdnQuery::Section (readonly)
Returns the top level section.
8 9 10 |
# File 'lib/mdn_query/document.rb', line 8 def section @section end |
#title ⇒ String (readonly)
5 6 7 |
# File 'lib/mdn_query/document.rb', line 5 def title @title end |
#url ⇒ String (readonly)
5 6 7 |
# File 'lib/mdn_query/document.rb', line 5 def url @url end |
Instance Method Details
#open ⇒ void
This method returns an undefined value.
Opens the document in the default web browser if a URL has been specified.
24 25 26 |
# File 'lib/mdn_query/document.rb', line 24 def open Launchy.open(@url) unless @url.nil? end |
#to_s ⇒ String Also known as: to_md
Returns the string representation of the document.
31 32 33 |
# File 'lib/mdn_query/document.rb', line 31 def to_s @section.to_s end |