Class: KizAPI::KeywordInContexts

Inherits:
Array
  • Object
show all
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

Instance Method Summary collapse

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

#dateObject (readonly)

Returns the value of attribute date.



80
81
82
# File 'lib/kizapi.rb', line 80

def date
  @date
end

#keywordObject (readonly)

Returns the value of attribute keyword.



80
81
82
# File 'lib/kizapi.rb', line 80

def keyword
  @keyword
end