CocoaPods trunk is moving to be read-only. Read more on the blog, there are 14 months to go.
| TestsTested | ✗ |
| LangLanguage | SwiftSwift |
| License | MIT |
| ReleasedLast Release | Jan 2016 |
| SPMSupports SPM | ✓ |
Maintained by Nikolai Vazquez.
Installation • Usage • License • Documentation
Roman is a Swift framework that allows for seamless Roman numeral conversion.
The Swift Package Manager is a decentralized dependency manager for Swift.
Add the project to your Package.swift.
import PackageDescription
let package = Package(
name: "MyAwesomeProject",
dependencies: [
.Package(url: "https://github.com/nvzqz/Roman.git",
majorVersion: 1)
]
)Import the Roman module.
import RomanSimply add the Roman.swift file into your project.
A Roman numeral string can be created from an instance of a type that conforms to IntegerType.
String(roman: 1478) // "MCDLXXVIII"
String(roman: 2743) // "MMDCCXLIII"
String(roman: 1226) // "MCCXXVI"
String(roman: 0) // nil
String(roman: -42) // nilAll types that conform to IntegerType can be initialized from a Roman numeral string.
The input string is case insensitive.
Int(roman: "III") // 3
Int(roman: "MIV") // 1004
Int(roman: "CdV") // 405Roman even supports irregular numerals that don’t use a short form.
Each of the following evaluates to true:
Int(roman: "IV") == Int(roman: "IIII")
Int(roman: "XX") == Int(roman: "VVVV")
Int(roman: "CD") == Int(roman: "CCCC")Invalid strings return nil.
Int(roman: "hello") == nil
Int(roman: "IIIXX") == nil
Int(roman: "XYZ") == nilAll types that conform to FloatingPointType can be initialized from a Roman numeral string.
Creating instances from Roman numerals works the same way as with IntegerType.
Roman is released under the MIT License.
All assets are released under the Creative Commons Attribution-ShareAlike 4.0 International License and can be found in the Assets folder.