delay109

package module
Version: v0.0.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 10, 2018 License: MIT Imports: 10 Imported by: 0

README

go-delay109

Delay information of Tokyu lines

What's this?

This library is simply parsing Tokyu delay certificate page and check if the train is delayed. It supports all lines of Toyku railway as bellow.

  • TY: Toyoko Line
  • MG: Meguro Line
  • DT: Den-en-toshi Line
  • OM: Oimachi Line
  • IK: Ikegami Line
  • TM: Tokyu Tamagawa Line
  • SG: Setagaya Line
  • KD: Kodomonokuni Line

See reference for details.

Example

Code
package main

import (
	"fmt"

	delay109 "github.com/nukosuke/go-delay109"
)

func main() {
	client := delay109.New(nil)
	status, _ := client.Search(&delay109.Query{
		Line:       delay109.DT,
		Year:       2018,
		Month:      1,
		Day:        1,
		Direction:  delay109.DirectionUp,
		TimePeriod: delay109.Before10am,
	})

	fmt.Println(status.LineNameJa())
	fmt.Println(status.DirectionText(), "方面")
	fmt.Println(status.DelayDuration().Minutes(), "分遅延")
}
Output
# This is sample, NOT actual information.
$ ./example
田園都市線
上り 方面
10 分遅延

Notice

Redistributing Tokyu official delay information is prohibited.
You can use this library only for your own purpose.

License

MIT

Documentation

Index

Constants

View Source
const (
	// DirectionUp 上り
	DirectionUp = 0
	// DirectionDown 下り
	DirectionDown = 10
)
View Source
const (
	// Before10am 始発〜10時
	Before10am = 1 + iota
	// After10am 10時以降
	After10am
)

Variables

This section is empty.

Functions

func DirectionText

func DirectionText(direction int) string

DirectionText 方面のテキスト(上り/下り)を取得する

func LineNameEn

func LineNameEn(id LineID) string

LineNameEn 路線の英語名を取得する

func LineNameJa

func LineNameJa(id LineID) string

LineNameJa 路線の日本語名を取得する

Types

type Client

type Client struct {
	// contains filtered or unexported fields
}

Client 遅延情報取得クライアント

func New

func New(h *http.Client) *Client

New Clientコンストラクタ

func (*Client) Search

func (c *Client) Search(q *Query) (*LineStatus, error)

Search 遅延情報を検索する

type LineID

type LineID int

LineID 路線識別子

const (
	// TY 東横線
	TY LineID = 1 + iota
	// MG 目黒線
	MG
	// DT 田園都市線
	DT
	// OM 大井町線
	OM
	// IK 池上線
	IK
	// TM 東急多摩川線
	TM
	// SG 世田谷線
	SG
	// KD こどもの国線
	KD
)

type LineStatus

type LineStatus struct {
	// contains filtered or unexported fields
}

LineStatus 路線ステータス

func (*LineStatus) DelayDuration

func (ls *LineStatus) DelayDuration() time.Duration

DelayDuration 遅延時間を返す

func (*LineStatus) DirectionText

func (ls *LineStatus) DirectionText() string

DirectionText 方向を返す

func (*LineStatus) LineDirection

func (ls *LineStatus) LineDirection() int

LineDirection 路線の方向を返す(上り/下り)

func (*LineStatus) LineID

func (ls *LineStatus) LineID() LineID

LineID 路線の識別番号を返す

func (*LineStatus) LineNameEn

func (ls *LineStatus) LineNameEn() string

LineNameEn 路線の英語名を返す

func (*LineStatus) LineNameJa

func (ls *LineStatus) LineNameJa() string

LineNameJa 路線の日本語名を返す

type Query

type Query struct {
	Line  LineID
	Year  int
	Month int
	Day   int

	// DirectionUp | DirectionDown
	Direction int

	// Before10am | After10am
	TimePeriod int
}

Query 検索クエリ

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
t or T : Toggle theme light dark auto
y or Y : Canonical URL