From 4e0b85e7919f6f7e7f78e52956885bc196ec7e0d Mon Sep 17 00:00:00 2001 From: Kanezoh Date: Tue, 16 Nov 2021 12:29:01 +0900 Subject: [PATCH] add page.cr comment --- src/mechanize/page.cr | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/mechanize/page.cr b/src/mechanize/page.cr index 9b082bd..eb5a8ad 100644 --- a/src/mechanize/page.cr +++ b/src/mechanize/page.cr @@ -8,6 +8,8 @@ require "./page/link" class MechanizeCr::Page < MechanizeCr::File include MechanizeCr::ElementMatcher + + # look at lexbor document.(https://github.com/kostya/lexbor#readme) delegate :css, to: parser property mech : Mechanize @@ -24,6 +26,9 @@ class MechanizeCr::Page < MechanizeCr::File end # return page title. + # ``` + # page.title # => String + # ``` def title : String title_node = css("title") if title_node.empty? @@ -34,6 +39,9 @@ class MechanizeCr::Page < MechanizeCr::File end # return all forms(`MechanizeCr::Form`) in the page. + # ``` + # page.forms # => Array(MechanizeCr::Form) + # ``` def forms : Array(MechanizeCr::Form) forms = css("form").map do |html_form| form = Form.new(html_form, self) @@ -42,7 +50,10 @@ class MechanizeCr::Page < MechanizeCr::File end.to_a end - # return all links(`MechanizeCr::PageContent::Link) in the page. + # return all links(`MechanizeCr::PageContent::Link`) in the page. + # ``` + # page.links # => Array(MechanizeCr::PageContent::Link) + # ``` def links : Array(MechanizeCr::PageContent::Link) links = %w{a area}.map do |tag| css(tag).map do |node|