Sha256: 6da6e785efa73bd9a64d91f78f70dec8c28d37703212d9fc8467a05a89e294c5

Contents?: true

Size: 1.6 KB

Versions: 1

Compression:

Stored size: 1.6 KB

Contents

# -*- coding: utf-8 -*-
require 'hiroshimarb/member'
require 'rubygems'
require 'launchy'
require 'uri'

module Hiroshimarb
  # コマンドラインから呼びだされる場合のサブコマンドを実装する
  module CLI
    # Hiroshim.rbのウェブサイトをブラウザで開く
    def open(key = nil)
      key ||= 'hiroshimarb'
      url = case key
            when 'hiroshimarb'
              'http://hiroshimarb.github.com'
            when 'oc-h'
              'http://oc-h.jp'
            when 'ipad'
              URI.encode 'http://kita.dyndns.org/wiki/?広島弁吹替シリーズ'
            when 'city'
              'http://www.city.hiroshima.lg.jp'
            when 'pref'
              'http://www.pref.hiroshima.lg.jp'
            end
      Launchy.open url
    end

    # Hiroshim.rbの情報を標準出力へ表示
    def info
      puts Information.information
    end

    # Hiroshima.rbのメンバーを標準出力へ表示
    def member
      Member.all.reduce(nil) do |acc, member|
        puts acc if acc
        puts member.to_s
        acc = '-'*80
      end
    end

    def help
        puts <<EOD
Usage: hiroshimarb command
Available commands:
  open    : open the website relevant to Hiroshima in a web browser
          : subcommands
          :    hiroshimarb - Hiroshim.rb [default]
          :    ipad        - 広島弁吹替シリーズ
          :    oc-h        - おしい広島県
          :    city        - 広島市
          :    pref        - 広島県
  info    : disploy information of Hiroshimar.rb
  member  : display the member of Hiroshima.rb
EOD
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
hiroshimarb-0.0.4 lib/hiroshimarb/cli.rb