Class: KizAPI::KeywordInContexts
- Inherits:
-
Array
- Object
- Array
- KizAPI::KeywordInContexts
- Defined in:
- lib/kizapi.rb
Overview
KeyWordInContext is a class for fetching 3 sentences in context including a keyword.
Defined Under Namespace
Classes: Context
Instance Attribute Summary collapse
-
#date ⇒ Object
readonly
Returns the value of attribute date.
-
#keyword ⇒ Object
readonly
Returns the value of attribute keyword.
Instance Method Summary collapse
-
#initialize(keyword) ⇒ KeywordInContexts
constructor
Fetch 3 sentences.
Constructor Details
#initialize(keyword) ⇒ KeywordInContexts
Fetch 3 sentences
83 84 85 86 87 88 89 90 91 |
# File 'lib/kizapi.rb', line 83 def initialize(keyword) @keyword = keyword uri = URI.parse(URI.escape(<<-URL.chomp)) http://kizasi.jp/kizapi.py?kw_expr=#{keyword}&type=kwic URL rss = RSS::Parser.parse(uri.read) @date = rss.channel.lastBuildDate super(rss.items.map{|item| Context.new(item)}) end |
Instance Attribute Details
#date ⇒ Object (readonly)
Returns the value of attribute date.
80 81 82 |
# File 'lib/kizapi.rb', line 80 def date @date end |
#keyword ⇒ Object (readonly)
Returns the value of attribute keyword.
80 81 82 |
# File 'lib/kizapi.rb', line 80 def keyword @keyword end |