add export
This commit is contained in:
parent
bcd54dc673
commit
f03b5f25f3
5 changed files with 50 additions and 0 deletions
|
@ -2,6 +2,8 @@ module CoordVisualize
|
|||
|
||||
using Dates
|
||||
|
||||
export CoordLog
|
||||
|
||||
include("typedef.jl")
|
||||
include("parser.jl")
|
||||
include("edit.jl")
|
||||
|
|
30
src/print.jl
30
src/print.jl
|
@ -0,0 +1,30 @@
|
|||
"""
|
||||
Export `log` to a file or `io::IO`.
|
||||
"""
|
||||
function export_log end
|
||||
|
||||
function export_log(log::CoordLog)
|
||||
"""
|
||||
CoordLog(
|
||||
$(log.coords),
|
||||
Dates.DateTime("$(log.logdate)"), "$(log.note)"
|
||||
)"""
|
||||
end
|
||||
|
||||
function export_log(logs::Vector{CoordLog})
|
||||
logs .|>
|
||||
export_log |>
|
||||
(vs -> join(vs, ",\n")) |>
|
||||
(s -> "[\n" * s * "\n]")
|
||||
end
|
||||
|
||||
function export_log(io::IO, log::CoordLog)
|
||||
write(io, export_log(log))
|
||||
end
|
||||
|
||||
function export_log(file::AbstractString, log::CoordLog)
|
||||
open(file, "w") do f
|
||||
export_log(f, log)
|
||||
end
|
||||
end
|
||||
|
|
@ -1,4 +1,5 @@
|
|||
using Dates
|
||||
import Base
|
||||
"""
|
||||
Stores a set of logs with its taken date datetime and supplemental note.
|
||||
"""
|
||||
|
@ -16,3 +17,7 @@ Get number of coordinates in `log`.
|
|||
function n_coords(log::CoordLog)::Integer
|
||||
size(log.coords)[1]
|
||||
end
|
||||
|
||||
Base.:(==)(x::CoordLog, y::CoordLog) = begin
|
||||
x.note == y.note && x.logdate == y.logdate && x.coords == y.coords
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue