File: web.rb

package info (click to toggle)
mikutter 5.0.4%2Bdfsg1-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 9,700 kB
  • sloc: ruby: 21,307; sh: 181; makefile: 19
file content (27 lines) | stat: -rw-r--r-- 763 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# -*- coding: utf-8 -*-

=begin rdoc
Web上のリソースを示す汎用的なModel。
これ自体が特別な機能は提供せず、単にURLがWeb上のリソースを指し示していることを表わすために使う。

例えば、URLはWebブラウザで開くことができるが、intentは最終的に全てModelに変換できなければならないため、Modelが用意されていない多くのURLは取り扱うことができない。
=end
module Plugin::Web
  class Web < Diva::Model
    register :web

    field.uri :perma_link

    handle ->uri{ %w<http https>.include?(uri.scheme) } do |uri|
      new(perma_link: uri)
    end

    def title
      perma_link.to_s
    end

    def description
      perma_link.to_s
    end
  end
end