parse

package
v0.2.5 Latest Latest
Warning

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

Go to latest
Published: Jun 24, 2022 License: Unlicense Imports: 7 Imported by: 0

Documentation

Overview

Package parse provides lexical analysis and parsing methods for twtr.

While usable as a stand alone parsing package, the twtr.Client type is better suited to high level applications.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Feed

func Feed(data io.Reader) <-chan FeedLine

Feed parses the data as a twtxt feed file.

See https://twtxt.readthedocs.io/en/latest/user/twtxtfile.html#format-specification

Types

type CommentLine

type CommentLine struct {
	// These are the metadata fields of the line, parsed as:
	//
	//     FIELD = VALUE
	//
	// Note that these are not required and may be empty.
	FIELD, VALUE string

	// CommentLine extends the Line type
	Line
}

CommentLine represents a line, parsed as a comment in a twtxt.txt file.

func NewCommentLine

func NewCommentLine(line string) (comment CommentLine)

NewCommentLine parses a new comment line from the given string.

func (CommentLine) AsCommentLine

func (comment CommentLine) AsCommentLine() (line CommentLine, ok bool)

AsCommentLine reports whether this FeedLine is a CommentLine and casts it appropriately.

func (CommentLine) AsTweetLine

func (comment CommentLine) AsTweetLine() (line TweetLine, ok bool)

AsTweetLine reports whether this FeedLine is a TweetLine and casts it appropriately.

type FeedLine

type FeedLine interface {
	// AsCommentLine reports whether this FeedLine is a CommentLine and casts it
	// appropriately
	AsCommentLine() (line CommentLine, ok bool)

	// AsTweetLine reports whether this FeedLine is a TweetLine and casts it
	// appropriately
	AsTweetLine() (line TweetLine, ok bool)
	// contains filtered or unexported methods
}

FeedLine represents either a CommentLine or a TweetLine, as either may appear in a twtxt.txt feed file.

type Line

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

Line is the basic unit of a parsed line, it represents the original text of the line as it was parsed, as well as any error that occurred during parsing.

func (Line) Err

func (line Line) Err() error

Err reports any error that may have occurred during parsing.

func (Line) String

func (line Line) String() string

String represents the line as it was originally parsed.

type TweetLine

type TweetLine struct {
	// These are the fields of the line, parsed as:
	//
	//    TIMESTAMP\tMESSAGE
	//
	// Note that any of these may be blank or missing, check the Err() method to
	// validate the line.
	TIMESTAMP time.Time
	MESSAGE   string

	// TweetLine extends the Line type
	Line
}

TweetLine represents a line, parsed as an entry in a twtxt.txt file.

func NewTweetLine

func NewTweetLine(line string) (tweet TweetLine)

NewTweetLine parses a new tweet line from the given string.

func (TweetLine) AsCommentLine

func (tweet TweetLine) AsCommentLine() (line CommentLine, ok bool)

AsCommentLine reports whether this FeedLine is a CommentLine and casts it appropriately.

func (TweetLine) AsTweetLine

func (tweet TweetLine) AsTweetLine() (line TweetLine, ok bool)

AsTweetLine reports whether this FeedLine is a TweetLine and casts it appropriately.

Jump to

Keyboard shortcuts

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