poetryengine

package module
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Feb 11, 2017 License: MIT Imports: 2 Imported by: 0

README

go-poetryengine

poetryengine is the engine of lottery poetry.

GoDoc Go Report Card Build Status Coverage Status

Installation

go get -u github.com/DestinyLab/go-poetryengine

Usage

package main

import (
  "fmt"

  p "github.com/DestinyLab/go-poetryengine"
)

func main() {
  poem := []p.Poem{
    {
      Title: "第一籤",
      Gua:   []string{"上上", "○○○○○"},
      Poem:  []string{"彩鳳呈祥瑞", "麒麟降帝都", "禍除迎福至", "喜氣自然生"},
      Item:  []string{"禍消福至", "求官得位", "求財大利", "婚姻成就", "出行大吉", "占病得安", "作事大吉", "考試得意"},
    },
    {
      Title: "第二籤",
      Gua:   []string{"上平", "○●●●●"},
      Poem:  []string{"從革宜更變", "時來合動遷", "龍門魚躍出", "凡骨作神仙"},
      Item:  []string{"行事得利", "作事可成", "占訟和吉", "求官得位", "走失見近", "婚姻成吉", "運途漸吉", "作事如意"},
    },
  }

  s := p.New(poem)

  fmt.Printf("get one:\n%v\n\n", s.Get(0).Title)
  fmt.Printf("get all:\n%v\n\n", s.GetList())
  fmt.Printf("total: %v\n", s.Total())
  fmt.Printf("random one:\n%v\n", s.Draw().Title)
}

Documentation

Overview

Package poetryengine is the engine of lottery poetry.

Example:

package main

import (
	"fmt"

	p "github.com/DestinyLab/go-poetryengine"
)

func main() {
	poem := []p.Poem{
		{
			Title: "第一籤",
			Gua:   []string{"上上", "○○○○○"},
			Poem:  []string{"彩鳳呈祥瑞", "麒麟降帝都", "禍除迎福至", "喜氣自然生"},
			Item:  []string{"禍消福至", "求官得位", "求財大利", "婚姻成就", "出行大吉", "占病得安", "作事大吉", "考試得意"},
		},
		{
			Title: "第二籤",
			Gua:   []string{"上平", "○●●●●"},
			Poem:  []string{"從革宜更變", "時來合動遷", "龍門魚躍出", "凡骨作神仙"},
			Item:  []string{"行事得利", "作事可成", "占訟和吉", "求官得位", "走失見近", "婚姻成吉", "運途漸吉", "作事如意"},
		},
	}

	s := p.New(poem)

	fmt.Printf("get one:\n%v\n\n", s.Get(0).Title)
	fmt.Printf("get all:\n%v\n\n", s.GetList())
	fmt.Printf("total: %v\n", s.Total())
	fmt.Printf("random one:\n%v\n", s.Draw().Title)
}

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Poem

type Poem struct {
	Title string   `json:"title"`
	Gua   []string `json:"gua"`
	Poem  []string `json:"poem"`
	Item  []string `json:"item"`
}

A Poem returns lottery-poetry.

type Suit

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

A Suit returns slice of Poem.

func New

func New(list []Poem) *Suit

New creates an instance of Suit.

func (*Suit) Draw

func (s *Suit) Draw() Poem

Draw picks random poem.

func (*Suit) Get

func (s *Suit) Get(poemid int) Poem

Get finds poem by ID.

func (*Suit) GetList

func (s *Suit) GetList() []Poem

GetList returns all poems.

func (*Suit) Total

func (s *Suit) Total() int

Total returns total number of Suit.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL